Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1889010lqb; Mon, 27 May 2024 00:16:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVWWrtvL/3bWYQOezqfXy+PDkqCK0fieuXidGNdCmyfEVX+QxSrpvE2PWbac05tb35P+uIFW+3yVoU/TqRnLZ9erm4lhJcDfnoi07IcxA== X-Google-Smtp-Source: AGHT+IGW5EgctwufydJwciZaZIa0SzppQGwFR8ok3PylyIpo9PE+/8albu+wBmQcBOJ1pE3nZpJH X-Received: by 2002:a17:90a:d709:b0:2be:7650:a321 with SMTP id 98e67ed59e1d1-2bf5e14fc2emr7075776a91.8.1716794166586; Mon, 27 May 2024 00:16:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716794166; cv=pass; d=google.com; s=arc-20160816; b=WQwCw8lOJ53VVUxRl5Uz78pfKn2FOvnYu4465pCNyW8N+pRNvseb/UBwXqZP2CyNtG VoFLd+ywUMm+mTubIF8jrT4E1bq6kahQi5eEMFo9ssv++LlHdjJD4RRsBWK2WlNL4kuH PQZoAZb2ivCydPrcWEyqpSiZyxSbitDGNm+odlAWWRRAFLQZCWSInWAxMK/b8f7dlCzu k5W3/+Xql75TXIcSqwg4cC7sekm5juGcUDGqbCzsoRXHyUG820Ns5F+B4HccvEwxraFH 0thZhOtBt+/opbERVQFz4E8V21I+VHWl8SKcy98+Sb94OROZ0YsHDxO3Kb5/mKzw/uVb J2KQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wzFPdlZqVo5PKSyt9wOZE+bRSKE7VsgsZElEVWfoDy0=; fh=q3MYVgFnlbIVvHsgS+vRgqhcopC4WV5VkW3niDfmgWQ=; b=oMO2y8bjB+FxdRKyWoqOe2MRWWlbhNy48TizlRdgbA6adGSu0fGyeaLTqoNBC92TTP 6fM/Ezwzc3hsORWQKDJA3m7g6p7B2FEMVesM5b4gAsTeW0q9MFkm4F8KRMcqrAPCkywU qPnZl61JRYkvk1aje2qXED29pOIpB5vQGc/rtLIXCo0AYwwm+3Hh8xN0QnM5cKynXkz7 tNn5UkOPYVSCWv2W3ucDUsMO5SR7nZcDZLtjLfu4h416eo+4dWNF1svYKo0anOUXYFRi ZZJSmmPpjAm4Oq2PlAm/80prkzcUSGq4eS5i45xxl/AgTM+pVTiraGN9H1pjFb8uLLx4 zC5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PmARSZdH; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-190123-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190123-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bf5fac6475si5649112a91.26.2024.05.27.00.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 00:16:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190123-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PmARSZdH; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-190123-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190123-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 11408B21492 for ; Mon, 27 May 2024 07:15:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C205917BA9; Mon, 27 May 2024 07:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PmARSZdH" Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 471D5208D1 for ; Mon, 27 May 2024 07:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716794146; cv=none; b=cq5L3Pq8iXf7jRYQwT1C58vaFUuqn5aHrtmYTiZWme0RJhj1/5XFn643/AlaZprp3rW8lNkQlaKrzCkn3QUmWHHCS6tQ1pQmUEQZRY7AOaKUMJp9gsY+jIBBOCfLphDM2S02lMqPTJjHlSSvfpv4k1gZ8aQhoUnBjgCqB7Mrrn0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716794146; c=relaxed/simple; bh=mwe8kOgRaHJINAiRajKjPR7tR6S5Am3qELO6PW9hBaY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VdFWzgh4qf2f4kv/MuKo5X++aDBVpYqFfsSKyDKav6Pv83uwDXV/17in84SOKMN8OoMl87yDBQvdkjSawFsyC/i1Y7oFnxbQ2amWFA6L6tvwfnRgKpgaVrDL7ShT22c3YZ6f/DEXkoXzQvWEE3D8+EYzF+PIf1wGccu6ZLxB51I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=PmARSZdH; arc=none smtp.client-ip=209.85.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-57863a8f4b2so2399044a12.0 for ; Mon, 27 May 2024 00:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716794144; x=1717398944; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=wzFPdlZqVo5PKSyt9wOZE+bRSKE7VsgsZElEVWfoDy0=; b=PmARSZdHHlQMvECKV26e+UmYNHQONltn8Dkq5DVhpEYv53a8kDt20lVB0XyNJQN0T2 cki62njd7gKPX8sEJ8h6cmTgQgNKU3GxOHf2Z11kRda6t1DV64ujDjgIVhKoAf2zziOW k57qYTEIeRlstInk6PzPP661e7/GTYhoLv4064rnZpJdr5BHz/ee27Xq2CXuRqGlGgcR 6wZ33rSZn+YhYljSzcX/OUgRn2Cs9OM40MOVHMWOf10DMqLecmblB4if0jSqK7rpjecy c4sKP+1Qc4M7UZ4o5YKki2jw2rU+p6Feg7wtI+TlRLWuHikGxRU91Q+9oyzvfA2KnPws Zc4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716794144; x=1717398944; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wzFPdlZqVo5PKSyt9wOZE+bRSKE7VsgsZElEVWfoDy0=; b=ijABBvaUHyS5s4Vd+bR5jYiEubqU4uNxrhDa49/hs7/Osbc9A3xKLDS8m6Xm6X0wG0 VIUrTAbw+9bLSys3afu02dUBuHVy20IGR7ymcjne4DPp+//nqceXgYkQPVx2wz02DMwj UXNf2HOUXXixvR5RExmSQ3lcIPWRjxndzHA04oA9OIk6TnGViNdX5Dfrn+RSSLvohYwD VW9Ci392nUr5oLJhkNhMGH+V9x3hO/xTGSJ5zQ59TBBsA96UbC3xKuSebfZD68aEH6Xs TaN3fiC5RstaADx/ucuvieOa4jKZicr25DQ6zitrJaxHqcJQ0rs8CUF08AhlfsiUH+R+ v7Fw== X-Forwarded-Encrypted: i=1; AJvYcCWu/DL7uRqYwD4oQRS7J3fQkKXNL1k6dx/Y2yEQneg8h1Fp2ecKsI5VgUJ1KRW4sZpvfY3Vjr2ZcrZl/1GnSHU5btPSTpbIqzhT/glj X-Gm-Message-State: AOJu0Yxro68T6T/vyxhn6nq0XYvFVKOyUZ1V4I8yzPdfJYjkTZ3QaPVC SqiJCrJ2HbpiDt6a9HMWmnuYLGLyGPOf3B/f+X6Wax7KD+kmDyP6DIHUKqNXk72zaR2ZH7nL97S 0 X-Received: by 2002:a50:d6d9:0:b0:578:e1f5:47e1 with SMTP id 4fb4d7f45d1cf-578e1f54b50mr3546015a12.34.1716794143546; Mon, 27 May 2024 00:15:43 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-579c73c771esm2141548a12.65.2024.05.27.00.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 00:15:43 -0700 (PDT) Date: Mon, 27 May 2024 10:15:39 +0300 From: Dan Carpenter To: Nam Cao Cc: Larry Finger , Florian Schilhabel , Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Nikita Zhandarovich , syzbot+83763e624cfec6b462cb@syzkaller.appspotmail.com Subject: Re: [PATCH] staging: rtl8712: remove unnecessary alignment of pxmitpriv->pxmitbuf Message-ID: <839d7d29-84ee-4da3-8024-67b79d581780@moroto.mountain> References: <20240525073229.4144612-1-namcao@linutronix.de> <92412c38-8fb0-4a81-9205-7735ae21459c@moroto.mountain> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <92412c38-8fb0-4a81-9205-7735ae21459c@moroto.mountain> On Mon, May 27, 2024 at 10:06:22AM +0300, Dan Carpenter wrote: > On Sat, May 25, 2024 at 09:32:29AM +0200, Nam Cao wrote: > > This driver wants pxmitpriv->pxmitbuf to be 4-byte aligned. This is ensured > > by allocating 4 more bytes than required with kmalloc(), then do the > > p = p + 4 - (p & 3) trick to make sure the pointer is 4-byte aligned. > > > > This is unnecessary. Pointers from kmalloc() are already at least > > 8-byte-aligned. > > > > Remove this alignment trick to simplify the code, and also to stop wasting > > 4 extra bytes of dynamic memory allocator. > > > > This also gets rid of a (false) warning from kmemleak. This 4-byte-aligned > > buffer is used to store pointers from kmalloc(). For 64-bit platforms, > > pointer size is 8 bytes and kmemleak only scans for pointers in 8-byte > > blocks, thus it misses the pointers stored in this 4-byte-aligned buffer > > and thinks that these pointers have been leaked. This is just a false > > warning, not a real problem. But still, it would be nice to get rid of > > these warnings. > > Are you sure it's a false positive? I've always wondered what happens > when you do: > > p = kmalloc(); > kfree((char *)p + 4); Ah, never mind, it actually frees p. It took me a while to figure out that it's actually pointers stored in the buffer which are reported as leaks and not the buffer itself. This was explained quite well in the commit message but I just misunderstood. regards, dan carpenter