Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com>,
	netdev@vger.kernel.org,
	Mateusz Polchlopek <mateusz.polchlopek@intel.com>,
	intel-wired-lan@lists.osuosl.org,
	Larysa Zaremba <larysa.zaremba@intel.com>
Subject: Re: [Intel-wired-lan] [PATCH iwl-net v2] ice: fix memleak in ice_init_tx_topology()
Date: Wed, 11 Sep 2024 11:12:49 -0700	[thread overview]
Message-ID: <795ab8e6-8759-4e7e-a8ed-c072ab5253ec@intel.com> (raw)
In-Reply-To: <2d5dbb96-d96b-4528-b098-ea1fb9c762f2@intel.com>



On 9/11/2024 1:37 AM, Przemek Kitszel wrote:
> On 9/10/24 23:30, Jacob Keller wrote:
>>
>>
>> On 9/10/2024 6:57 AM, Przemek Kitszel wrote:
>>> Fix leak of the FW blob (DDP pkg).
>>>
>>> Make ice_cfg_tx_topo() const-correct, so ice_init_tx_topology() can avoid
>>> copying whole FW blob. Copy just the topology section, and only when
>>> needed. Reuse the buffer allocated for the read of the current topology.
>>>
>>> This was found by kmemleak, with the following trace for each PF:
>>>      [<ffffffff8761044d>] kmemdup_noprof+0x1d/0x50
>>>      [<ffffffffc0a0a480>] ice_init_ddp_config+0x100/0x220 [ice]
>>>      [<ffffffffc0a0da7f>] ice_init_dev+0x6f/0x200 [ice]
>>>      [<ffffffffc0a0dc49>] ice_init+0x29/0x560 [ice]
>>>      [<ffffffffc0a10c1d>] ice_probe+0x21d/0x310 [ice]
>>>
>>> Constify ice_cfg_tx_topo() @buf parameter.
>>> This cascades further down to few more functions.
>>>
>>
>> Nice!
>>
>> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> 
> Thanks!
> 
>>
>>> Fixes: cc5776fe1832 ("ice: Enable switching default Tx scheduler topology")
>>> CC: Larysa Zaremba <larysa.zaremba@intel.com>
>>> CC: Jacob Keller <jacob.e.keller@intel.com>
>>> CC: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com>
>>> CC: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
>>> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
>>> ---
>>> this patch obsoletes two other, so I'm dropping RB tags
>>> v1, iwl-net: https://lore.kernel.org/netdev/20240904123306.14629-2-przemyslaw.kitszel@intel.com/
>>>      wrong assumption that ice_get_set_tx_topo() does not modify the buffer
>>>      on adminq SET variant, it sometimes does, to fill the response, thanks
>>>      to Pucha Himasekhar Reddy for finding it out;
>>> almost-const-correct iwl-next patch:
>>> https://lore.kernel.org/intel-wired-lan/20240904093135.8795-2-przemyslaw.kitszel@intel.com
>>> it was just some of this patch, now it is const-correct
>>> ---
>>
>> Right. So now we're doing the const correctness in this patch along with
>> the fix?
> 
> yes
> 
>>
>> Would it make sense to fix the copy issue but leave const updates to the
>> next tree?
>>
>> I think I'm fine with this, but wonder if it will make backporting a bit
>> more difficult? Probably not, given that this code is rarely modified.
> 
> hard to say, but I think one commit will make it a little bit easier, as
> there will be smaller number of possible sets of commits applied
> (at least in this case)
> 
>>
>> The const fixes are also relatively smaller than I anticipated :D
> 
> just adding kfree(), knowing the proper solution is to make code
> const-correct, is just a workaround, not a proper fix
> 
> change is still rather small, and splitting into two would require
> postponing -next one to be after -net (as it will just remove the added
> kfree())
> 

Well I was thinking of splitting it as the change in this patch where
you move the buffer copy, and change how we allocate things but with a
forced cast, instead of changing all the function prototypes to const.

However, I think this is small enough its fine as-is.

>>
>> Thanks,
>> Jake
> 

  reply	other threads:[~2024-09-11 18:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10 13:57 [Intel-wired-lan] [PATCH iwl-net v2] ice: fix memleak in ice_init_tx_topology() Przemek Kitszel
2024-09-10 21:30 ` Jacob Keller
2024-09-11  8:37   ` Przemek Kitszel
2024-09-11 18:12     ` Jacob Keller [this message]
2024-09-18  7:57 ` Pucha, HimasekharX Reddy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=795ab8e6-8759-4e7e-a8ed-c072ab5253ec@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=himasekharx.reddy.pucha@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=larysa.zaremba@intel.com \
    --cc=mateusz.polchlopek@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=przemyslaw.kitszel@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox