All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v3 1/2] usbnet: ipheth: fix risk of NULL pointer deallocation
@ 2023-05-27 13:03 Foster Snowhill
  2023-05-27 13:03 ` [PATCH net-next v3 2/2] usbnet: ipheth: add CDC NCM support Foster Snowhill
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Foster Snowhill @ 2023-05-27 13:03 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>
---
v3:
  - 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] 11+ messages in thread

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-27 13:03 [PATCH net-next v3 1/2] usbnet: ipheth: fix risk of NULL pointer deallocation Foster Snowhill
2023-05-27 13:03 ` [PATCH net-next v3 2/2] usbnet: ipheth: add CDC NCM support Foster Snowhill
2023-05-30 10:58   ` Paolo Abeni
2023-05-31 13:14     ` George Valkov
2023-05-31 15:10     ` Foster Snowhill
2023-06-01  8:09       ` Paolo Abeni
2023-05-27 14:50 ` [PATCH net-next v3 1/2] usbnet: ipheth: fix risk of NULL pointer deallocation Simon Horman
2023-05-30 11:02 ` Paolo Abeni
2023-05-30 11:09   ` George Valkov
2023-05-30 11:11   ` George Valkov
2023-05-30 13:41     ` Paolo Abeni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.