netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v4 1/4] usbnet: ipheth: fix risk of NULL pointer deallocation
@ 2023-06-07 13:56 Foster Snowhill
  2023-06-07 13:57 ` [PATCH net-next v4 2/4] usbnet: ipheth: transmit URBs without trailing padding Foster Snowhill
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Foster Snowhill @ 2023-06-07 13:56 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Georgi Valkov, Simon Horman, Jan Kiszka, linux-usb, netdev

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-06-09 11:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-07 13:56 [PATCH net-next v4 1/4] usbnet: ipheth: fix risk of NULL pointer deallocation Foster Snowhill
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

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).