From: Foster Snowhill <forst@pen.gy>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Georgi Valkov <gvalkov@gmail.com>,
Simon Horman <simon.horman@corigine.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH net-next v4 1/4] usbnet: ipheth: fix risk of NULL pointer deallocation
Date: Wed, 7 Jun 2023 15:56:59 +0200 [thread overview]
Message-ID: <20230607135702.32679-1-forst@pen.gy> (raw)
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. While kfree ignores NULL pointers,
and the existing code is safe, it is a better design to rearrange
the goto labels and avoid this.
Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
Signed-off-by: Foster Snowhill <forst@pen.gy>
---
v4:
No change
v3: https://lore.kernel.org/netdev/20230527130309.34090-1-forst@pen.gy/
- Reword commit msg to indicate design improvement rather than bugfix
- Add missing signoff for Foster Snowhill
No code changes
v2: https://lore.kernel.org/netdev/20230525194255.4516-1-forst@pen.gy/
- Factor out goto label change from v1 into this separate patch
v1: n/a
Part of https://lore.kernel.org/netdev/20230516210127.35841-1-forst@pen.gy/
---
drivers/net/usb/ipheth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
index 6a769df0b..8875a3d0e 100644
--- a/drivers/net/usb/ipheth.c
+++ b/drivers/net/usb/ipheth.c
@@ -510,8 +510,8 @@ static int ipheth_probe(struct usb_interface *intf,
ipheth_free_urbs(dev);
err_alloc_urbs:
err_get_macaddr:
-err_alloc_ctrl_buf:
kfree(dev->ctrl_buf);
+err_alloc_ctrl_buf:
err_endpoints:
free_netdev(netdev);
return retval;
--
2.40.1
next reply other threads:[~2023-06-07 14:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 13:56 Foster Snowhill [this message]
2023-06-07 13:57 ` [PATCH net-next v4 2/4] usbnet: ipheth: transmit URBs without trailing padding Foster Snowhill
2023-06-07 13:57 ` [PATCH net-next v4 3/4] usbnet: ipheth: add CDC NCM support Foster Snowhill
2023-06-07 13:57 ` [PATCH net-next v4 4/4] usbnet: ipheth: update Kconfig description Foster Snowhill
2023-06-09 9:30 ` [PATCH net-next v4 1/4] usbnet: ipheth: fix risk of NULL pointer deallocation patchwork-bot+netdevbpf
2023-06-09 10:42 ` George Valkov
2023-06-09 11:09 ` Greg KH
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=20230607135702.32679-1-forst@pen.gy \
--to=forst@pen.gy \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gvalkov@gmail.com \
--cc=jan.kiszka@siemens.com \
--cc=kuba@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=simon.horman@corigine.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).