From: Jesse Brandeburg <jesse.brandeburg@intel.com>
To: Julia Lawall <Julia.Lawall@inria.fr>, Jakub Kicinski <kuba@kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
<kernel-janitors@vger.kernel.org>, <netdev@vger.kernel.org>,
<intel-wired-lan@lists.osuosl.org>,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
David Laight <David.Laight@aculab.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@resnulli.us>,
"Jonathan Cameron" <jic23@kernel.org>,
Kees Cook <keescook@chromium.org>,
Lukasz Czapnik <lukasz.czapnik@intel.com>,
Paolo Abeni <pabeni@redhat.com>,
"Pucha Himasekhar Reddy" <himasekharx.reddy.pucha@intel.com>,
Markus Elfring <Markus.Elfring@web.de>,
Dan Williams <dan.j.williams@intel.com>
Subject: Re: [PATCH net] ice: Fix freeing uninitialized pointers
Date: Thu, 21 Mar 2024 15:27:47 -0700 [thread overview]
Message-ID: <b9dc2c7a-2688-4a7b-8482-1e762c39449c@intel.com> (raw)
In-Reply-To: <F2FBADE8-EDF9-4987-A97B-CF4D2D1452E0@inria.fr>
On 3/21/2024 1:20 PM, Julia Lawall wrote:
> Does one prefer an initialization of null at the top of the function
> or an initialization to a meaningful value in the middle of the
> function ?
I think the latter.
There was a related patch explaining the direction, from Dan posted here:
https://lore.kernel.org/all/171097196970.1011049.9726486429680041876.stgit@dwillia2-xfh.jf.intel.com/
We had been having some internal discussions about use of __free(kfree)
in the ice driver.
The gist of it is that we should instead be using inline declarations,
which I also agree is a reasonable style for this. It more clearly shows
the __free(kfree) and the allocation (kzalloc, kcalloc, etc) on the same
(or virtually the same) line of code.
I'm curious if Jakub would dislike this less? Accept?
as an example:
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c
b/drivers/net/ethernet/intel/ice/ice_common.c
index 88c86de82e09..822628d25b2f 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -1003,8 +1003,6 @@ static void ice_get_itr_intrl_gran(struct ice_hw *hw)
*/
int ice_init_hw(struct ice_hw *hw)
{
- struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) = NULL;
void *mac_buf __free(kfree) = NULL;
u16 mac_buf_len;
int status;
@@ -1083,7 +1081,8 @@ int ice_init_hw(struct ice_hw *hw)
if (status)
goto err_unroll_sched;
- pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
+ struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) =
+ kzalloc(sizeof(*pcaps), GFP_KERNEL);
if (!pcaps) {
status = -ENOMEM;
goto err_unroll_sched;
Any thoughts?
next prev parent reply other threads:[~2024-03-21 22:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-16 9:44 Dan Carpenter
2024-03-18 7:58 ` Jiri Pirko
2024-03-18 8:10 ` Dan Carpenter
2024-03-19 19:43 ` Jakub Kicinski
2024-03-20 5:01 ` Dan Carpenter
2024-03-20 7:32 ` Julia Lawall
2024-03-20 16:33 ` Jonathan Cameron
2024-03-21 3:29 ` Jakub Kicinski
2024-03-21 9:59 ` Przemek Kitszel
2024-03-21 10:34 ` Dan Carpenter
2024-03-20 12:18 ` Markus Elfring
2024-03-21 17:59 ` Markus Elfring
2024-03-21 18:03 ` Andy Shevchenko
2024-03-21 18:14 ` Markus Elfring
2024-03-21 20:20 ` Julia Lawall
2024-03-21 22:27 ` Jesse Brandeburg [this message]
2024-03-22 1:48 ` Jakub Kicinski
2024-03-22 1:56 ` Jakub Kicinski
2024-03-22 7:24 ` Julia Lawall
2024-03-22 15:03 ` Jakub Kicinski
2024-03-22 5:30 ` Dan Carpenter
2024-03-22 8:48 ` Markus Elfring
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=b9dc2c7a-2688-4a7b-8482-1e762c39449c@intel.com \
--to=jesse.brandeburg@intel.com \
--cc=David.Laight@aculab.com \
--cc=Julia.Lawall@inria.fr \
--cc=Markus.Elfring@web.de \
--cc=aleksander.lobakin@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=dan.carpenter@linaro.org \
--cc=dan.j.williams@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=himasekharx.reddy.pucha@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jic23@kernel.org \
--cc=jiri@resnulli.us \
--cc=keescook@chromium.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.czapnik@intel.com \
--cc=maciej.fijalkowski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--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
all inboxes | Powered by JetHome®