RE: [Intel-wired-lan] [PATCH v2] net: ethernet: fix uninitialized pointers with free attr

From: Loktionov, Aleksandr

Date: Thu Nov 06 2025 - 05:18:53 EST




> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@xxxxxxxxxx> On Behalf
> Of Ally Heev
> Sent: Thursday, November 6, 2025 11:09 AM
> To: Nguyen, Anthony L <anthony.l.nguyen@xxxxxxxxx>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@xxxxxxxxx>; Andrew Lunn
> <andrew+netdev@xxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>; Eric
> Dumazet <edumazet@xxxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>; Paolo
> Abeni <pabeni@xxxxxxxxxx>; K. Y. Srinivasan <kys@xxxxxxxxxxxxx>;
> Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>; Wei Liu <wei.liu@xxxxxxxxxx>;
> Cui, Dexuan <decui@xxxxxxxxxxxxx>
> Cc: intel-wired-lan@xxxxxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; linux-hyperv@xxxxxxxxxxxxxxx; Dan Carpenter
> <dan.carpenter@xxxxxxxxxx>; Ally Heev <allyheev@xxxxxxxxx>
> Subject: [Intel-wired-lan] [PATCH v2] net: ethernet: fix uninitialized
> pointers with free attr
>
> Uninitialized pointers with `__free` attribute can cause undefined
> behaviour as the memory assigned(randomly) to the pointer is freed
> automatically when the pointer goes out of scope
>
> net/ethernet doesn't have any bugs related to this as of now, but it
> is better to initialize and assign pointers with `__free` attr in one
> statement to ensure proper scope-based cleanup
>
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/
> Signed-off-by: Ally Heev <allyheev@xxxxxxxxx>
> ---
> Changes in v2:
> - fixed non pointer initialization to NULL
> - NOTE: drop v1
> - Link to v1: https://lore.kernel.org/r/20251105-aheev-uninitialized-
> free-attr-net-ethernet-v1-1-f6ea84bbd750@xxxxxxxxx
> ---
...

> Best regards,
> --
> Ally Heev <allyheev@xxxxxxxxx>

Good day, Ally

Thanks for addressing the cleanup attribute initialization.
A few upstream‑style nits before this can go in:

Commit message:
Use US spelling: behavior instead of behaviour.
Expand abbreviations: replace attr with attribute.
Drop speculative sentence: “net/ethernet doesn't have any bugs …” – not needed for a fix commit.
Minor grammar: add a period before “net/ethernet”; remove parentheses in assigned(randomly).

Changelog:
Hyphenate “non‑pointer” in “fixed non pointer initialization to NULL”.

Subject line:
net: ethernet: fix uninitialized pointers with __free attribute (spell out “attribute”).


Code style:
The new declaration + initializer is good, but please ensure both hunks stay within ~80 columns in drivers/net/*.
Wrapping like this is fine:

struct ice_flow_prof_params *params __free(kfree) =
kzalloc(sizeof(*params), GFP_KERNEL);

No functional issues found; just these style and commit message cleanups.

Thanks,
Alex