From: Simon Horman <simon.horman@corigine.com>
To: George Valkov <gvalkov@gmail.com>
Cc: Foster Snowhill <forst@pen.gy>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-usb <linux-usb@vger.kernel.org>,
Linux Netdev List <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v2 1/2] usbnet: ipheth: fix risk of NULL pointer deallocation
Date: Fri, 26 May 2023 10:41:54 +0200 [thread overview]
Message-ID: <ZHBw0l76XThhVS2Z@corigine.com> (raw)
In-Reply-To: <C0FADE3B-5422-444A-8F09-32BE215B5E88@gmail.com>
On Fri, May 26, 2023 at 10:33:21AM +0200, George Valkov wrote:
>
> > On 26 May 2023, at 10:52 AM, Simon Horman <simon.horman@corigine.com> wrote:
> >
> > On Thu, May 25, 2023 at 09:42:54PM +0200, Foster Snowhill wrote:
> >> From: Georgi Valkov <gvalkov@gmail.com>
> >>
> >> The cleanup precedure in ipheth_probe will attempt to free a
> >> NULL pointer in dev->ctrl_buf if the memory allocation for
> >> this buffer is not successful. Rearrange the goto labels to
> >> avoid this risk.
> >
> > Hi Georgi and Foster,
> >
> > kfree will ignore a NULL argument, so I think the existing code is safe.
> > But given the name of the label I do agree there is scope for a cleanup
> > here.
>
> It’s good to know that precaution has been taken in kfree to avoid this, yet at
> my opinion knowingly attempting to free a NULL pointer is a red flag and bad
> design. Likely a misplaced label.
>
> > Could you consider rewording the patch description accordingly?
>
> What would you like me to use as title and description? Can I use this?
>
> usbnet: ipheth: avoid kfree with a NULL pointer
>
> The cleanup precedure in ipheth_probe will attempt to free a
> NULL pointer in dev->ctrl_buf if the memory allocation for
> this buffer is not successful. While kfree ignores NULL pointers,
> and the existing code is safe, it is a better design to rearrange
> the goto labels and avoid this.
Thanks, that looks good to me.
> >> Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
> >
> > If Georgi is the author of the patch, which seems to be the case,
> > then the above is correct. But as the patch is being posted by Foster
> > I think it should be followed by a Signed-off-by line for Foster.
>
> Yes, I discovered the potential issue and authored the patch to help. We’ll
> append Signed-off-by Foster as you suggested. Thanks Simon!
>
> Something like that?
Yes, I think that sounds good.
Please wait 24h before the posting of v2 before posting v3,
to allow time for more review of v3 (from others).
...
prev parent reply other threads:[~2023-05-26 8:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 19:42 [PATCH net-next v2 1/2] usbnet: ipheth: fix risk of NULL pointer deallocation Foster Snowhill
2023-05-25 19:42 ` [PATCH net-next v2 2/2] usbnet: ipheth: add CDC NCM support Foster Snowhill
2023-05-26 7:52 ` [PATCH net-next v2 1/2] usbnet: ipheth: fix risk of NULL pointer deallocation Simon Horman
2023-05-26 8:33 ` George Valkov
2023-05-26 8:41 ` Simon Horman [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=ZHBw0l76XThhVS2Z@corigine.com \
--to=simon.horman@corigine.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=forst@pen.gy \
--cc=gvalkov@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).