From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: "Jagielski, Jedrzej" <jedrzej.jagielski@intel.com>,
"intel-wired-lan@lists.osuosl.org"
<intel-wired-lan@lists.osuosl.org>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"Kitszel, Przemyslaw" <przemyslaw.kitszel@intel.com>
Subject: Re: [Intel-wired-lan] [PATCH iwl-net v3] ice: Fix memory management in ice_ethtool_fdir.c
Date: Mon, 10 Jul 2023 13:48:04 -0700 [thread overview]
Message-ID: <25d3cd3d-e3c6-d3ef-d15e-8db497b03849@intel.com> (raw)
In-Reply-To: <DM6PR11MB273133BC65028765D6739FB8F030A@DM6PR11MB2731.namprd11.prod.outlook.com>
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/
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
prev parent reply other threads:[~2023-07-10 20:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-06 9:19 [Intel-wired-lan] [PATCH iwl-net v3] ice: Fix memory management in ice_ethtool_fdir.c Jedrzej Jagielski
2023-07-07 17:15 ` Tony Nguyen
2023-07-10 12:53 ` Jagielski, Jedrzej
2023-07-10 20:48 ` Tony Nguyen [this message]
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=25d3cd3d-e3c6-d3ef-d15e-8db497b03849@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jedrzej.jagielski@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