From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 9F875211499 for ; Mon, 8 Dec 2025 03:07:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765163253; cv=none; b=N8VsBf84ti3l1nSyfO0Wk4FZJIlzN+k9tAN4Zm+9L7wG/4MD9gdCUfzwU88YHjs1o3/chDkSSm5q4NIl5b3vQ6QymhHnJ8rJ9ypD3CrqcC0IKbY8TOOcKLJwPJ7/R+7E/0RFOK8ET1qPtpFS7556CQCpr2P3hjYLZwSLk4aqlz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765163253; c=relaxed/simple; bh=cWQlXLg2oAF75NLRYyi4rsXiifU/frpwJu+/Rp1ZA2k=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=b7ia0QhenX3agdnnVVU0FGdJPEfm7hMpZhuEvILgOiR179D4uMKOmxJh2gUSAEtZXD1q2nGgvzKk+UfJSURHQk5Kmo7uw+lKFtASXjd/Y/JlaFUlC9rEVhB4wPAa4sJFZRehMhwbhluTEoGjq3afiL7lPM56sMt8CA3DFiuv20s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NFge7lBX; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NFge7lBX" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-299d40b0845so66490015ad.3 for ; Sun, 07 Dec 2025 19:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765163251; x=1765768051; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=cWQlXLg2oAF75NLRYyi4rsXiifU/frpwJu+/Rp1ZA2k=; b=NFge7lBXRkH4WqTxCxH3rkPJ44Zpu2Ec6lOdcIFmvEwq8S/nPkIDgJelFwewtVVBP4 kXPF0AejEiwaWEuS/la2dL1zGTb5Xx1Qopo2Pg4W10hF7S9bNj/H6vkaZmdLNH61VpTG 32bq4Sxg3lZ7AKCdA4ahjjTBdsE99G+diQwEY7jBo4+eBCgRX+i44mqcf6ijuLpXpBst wATJ4qG5Y3jI6VtBDF/yzfCDtGyezrmFzpIs4khmY2zD38zSPyaSZLxu7Y57eYxW3A1K hW6vZFJ6MdwiXLdwpNKf1iTAoUQIcnXY6meRwlM6dnA63KgM62+VDa0z9jjDZEEZWjpx DzKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765163251; x=1765768051; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cWQlXLg2oAF75NLRYyi4rsXiifU/frpwJu+/Rp1ZA2k=; b=HAhG6Dyb9PgVbRfW9yLuWEH8uX+dAGabG3UYIdkD/aTOxPvhRJ0G4KxHe+XyatDSwU yrlcapP2dPGn1W8ogAz9+SGDugM+z5/8vn6y0mleZKJPf1+uZBpWZvsgdex1wRHpSnxr vizmuxn6spd5c5+6Jm315aJU84VUs8extSzDFpZ+Ng/NfV3wrvTbAKAwCUdxEdKzF8ZN kkP0DnJmhnoh9KkAqQBQ8xRYWQk8KCZPrAdOQri6zpOir27lLu05aFMBznnuczb/Qe9c JaT2Yphkxgmd/5T+QhoVY1W10YFt1B2EHZgMsU1u2G96WM4uKvBMTYxka1AtE7w87BJp tUvQ== X-Forwarded-Encrypted: i=1; AJvYcCVQgyGmSPQydU9PG28fukZMmZs3qcBVtLwRZJtd7qGVtdfDjRzL8jbikj0gZhFIO5PZ8ZqCaktBeHLs5Ms=@vger.kernel.org X-Gm-Message-State: AOJu0YyqPZKf2W+2DQj1FfK69bqPBCjrifEbbZuVBOL4iU1seuBgGquB GfbuLtJUVpxaZqg4/BTI0HdXiSVbo0DjKxU6+63fFFw6UlsA7pBkNl9X X-Gm-Gg: ASbGncskvGLLfEXBR8jCNbeKBWsMVCNBIRgwSPw0hYJjvIQtUozd7THINImoymA96p5 V4G2c0l+bVz4W7jMkM9qGy2RRuEm4FKVuFe/gkYvZgQRG+0TrcrEkpOvWd/2poeplN2EVst6KRr +3vRS2Ve0thNJY82ohtWwAXjnKxYUQjnYErTUcS31HYUDI8nf2Cb0/mn58agyBQVeZXNRXfst/a UHO3nEPXZFOEE1HLa++CX/7by7BrfehW94QXH3QBrhZSuMhlP9ucWbZ3udVgcSSRXH/KqMEoGc1 AO+xHqfmEuaAba+9ma/pZcLirovaaFPCwxh2VX+ommKA2SHjoprL6GggRc31PbB6Dc8Ucp6Lhn+ Wv4VJ85le000XS0EzJ0w4XvqgNEaIcrxJDXHJLFOc8Bh8ylX/V4qeNbcUq9wXmrMQy5HTH8Xqtt XxhExKZKrBuFH3hc04/1podITVIlKU5em/fUUVa0rHkQi15ljfdQ== X-Google-Smtp-Source: AGHT+IGclfbgYDV+2PprDNhoMS/qASDyleKSKZkgks8aJAQqaFHDlkmA3RGKrzkqi7Tvl94BT/sCTA== X-Received: by 2002:a17:903:2287:b0:264:70da:7a3b with SMTP id d9443c01a7336-29df5dec918mr73703385ad.49.1765163250925; Sun, 07 Dec 2025 19:07:30 -0800 (PST) Received: from ?IPv6:2401:4900:8fcc:9f:1de4:3838:6ac:e885? ([2401:4900:8fcc:9f:1de4:3838:6ac:e885]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29daeaabf7csm107759555ad.79.2025.12.07.19.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Dec 2025 19:07:30 -0800 (PST) Message-ID: Subject: Re: [Intel-wired-lan] [RFT net-next PATCH RESEND 0/2] ethernet: intel: fix freeing uninitialized pointers with __free From: ally heev To: Przemek Kitszel , Tony Nguyen , Jakub Kicinski , Paolo Abeni Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Dan Carpenter , Andrew Lunn , "David S. Miller" , Eric Dumazet , Alexander Lobakin , Simon Horman Date: Mon, 08 Dec 2025 08:37:24 +0530 In-Reply-To: References: <20251124-aheev-fix-free-uninitialized-ptrs-ethernet-intel-v1-0-a03fcd1937c0@gmail.com> <81053279-f2da-420c-b7a1-9a81615cd7ca@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-0+deb13u1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2025-12-03 at 09:45 +0100, Przemek Kitszel wrote: > On 12/3/25 09:09, ally heev wrote: > > On Tue, 2025-12-02 at 10:17 -0800, Tony Nguyen wrote: > > >=20 > > > On 12/2/2025 11:47 AM, ally heev wrote: > > > > On Mon, 2025-12-01 at 13:40 -0800, Tony Nguyen wrote: > > > > >=20 > > > > > On 11/23/2025 11:40 PM, Ally Heev wrote: > > > > > > Uninitialized pointers with `__free` attribute can cause undefi= ned > > > > > > behavior as the memory assigned randomly to the pointer is free= d > > > > > > automatically when the pointer goes out of scope. > > > > > >=20 > > > > > > We could just fix it by initializing the pointer to NULL, but, = as usage of > > > > > > cleanup attributes is discouraged in net [1], trying to achieve= cleanup > > > > > > using goto > > > > >=20 > > > > > These two drivers already have multiple other usages of this. All= the > > > > > other instances initialize to NULL; I'd prefer to see this do the= same > > > > > over changing this single instance. > > > > >=20 > > > >=20 > > > > Other usages are slightly complicated to be refactored and might ne= ed > > > > good testing. Do you want me to do it in a different series? > > >=20 > > > Hi Ally, > > >=20 > > > Sorry, I think I was unclear. I'd prefer these two initialized to NUL= L, > > > to match the other usages, over removing the __free() from them. > >=20 > > I had a patch for that already, but, isn't using __free discouraged in > > networking drivers [1]? Simon was against it [2] >=20 > you see, the construct is discouraged, so we don't use it everywhere, > but cleaning up just a little would not change the state of the matter > (IOW we will still be in "driver has some __free() usage" state). >=20 But still we can just fix the uninitialized ones the right way [1] right? since we have to fix them anyway. There already a patch [2] for that [1] https://lore.kernel.org/lkml/CAHk-=3DwiCOTW5UftUrAnvJkr6769D29tF7Of79gUjdQH= S_TkF5A@mail.gmail.com/ [2] https://lore.kernel.org/all/20251106-aheev-uninitialized-free-attr-net-ethe= rnet-v3-1-ef2220f4f476@gmail.com/ > TBH, I would not spent my time "undoing" all of the __free() that we > have already, especially the testing part sounds not fun. +1 >=20 > Turning all usage points to "=3D NULL" is orthogonal, and would be great. >=20 > >=20 > > [2] https://lore.kernel.org/all/aQ9xp9pchMwml30P@horms.kernel.org/ > > [1] https://docs.kernel.org/process/maintainer-netdev.html#using-device= -managed-and-cleanup-h-constructs > >=20 > > Regards, > > Ally > >=20