[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <25d3cd3d-e3c6-d3ef-d15e-8db497b03849@intel.com>
Date: Mon, 10 Jul 2023 13:48:04 -0700
From: Tony Nguyen <anthony.l.nguyen@...el.com>
To: "Jagielski, Jedrzej" <jedrzej.jagielski@...el.com>,
"intel-wired-lan@...ts.osuosl.org" <intel-wired-lan@...ts.osuosl.org>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>, mschmidt
<mschmidt@...hat.com>, "Kitszel, Przemyslaw" <przemyslaw.kitszel@...el.com>
Subject: Re: [PATCH iwl-net v3] ice: Fix memory management in
ice_ethtool_fdir.c
On 7/10/2023 5:53 AM, Jagielski, Jedrzej wrote:
...
>>> - seg = devm_kzalloc(dev, sizeof(*seg), GFP_KERNEL);
>>> - if (!seg)
>>> - return -ENOMEM;
>>> -
>>> - tun_seg = devm_kcalloc(dev, ICE_FD_HW_SEG_MAX, sizeof(*tun_seg),
>>> - GFP_KERNEL);
>>> - if (!tun_seg) {
>>> - devm_kfree(dev, seg);
>>> - return -ENOMEM;
>>> + seg = kzalloc(sizeof(*seg), GFP_KERNEL);
>>> + tun_seg = kcalloc(ICE_FD_HW_SEG_MAX, sizeof(*tun_seg), GFP_KERNEL);
>>> + if (!tun_seg || !seg) {
>>> + ret = -ENOMEM;
>>> + goto exit;
>>
>> IIRC individual checks and goto's are preferred over combining them.
>
> For both cases there is the same behavior so it was done due to limit
> the line redundancy, but if you think it is better to split them up i
> can do this
Please go back to individual checks; I found the previous comment [1].
"Don't do combined error checking, add appropriate labels for each case."
Also, as you're changing the allocation to not use the managed
allocation, you're going to need to find the related (non-error) free
and change those to be "regular" kfree as well.
Thanks,
Tony
[1] https://lore.kernel.org/netdev/20221115210239.3a1c05ba@kernel.org/
Powered by blists - more mailing lists