d9d6f36fcef385e35e390f0de4caad5fde83095e
[openwrt/staging/ansuel.git] /
1 From 2203718c2f59ffdd6c78d54e5add594aebb4461e Mon Sep 17 00:00:00 2001
2 From: Georgi Valkov <gvalkov@gmail.com>
3 Date: Wed, 7 Jun 2023 15:56:59 +0200
4 Subject: [PATCH 1/4] usbnet: ipheth: fix risk of NULL pointer deallocation
5
6 The cleanup precedure in ipheth_probe will attempt to free a
7 NULL pointer in dev->ctrl_buf if the memory allocation for
8 this buffer is not successful. While kfree ignores NULL pointers,
9 and the existing code is safe, it is a better design to rearrange
10 the goto labels and avoid this.
11
12 Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
13 Signed-off-by: Foster Snowhill <forst@pen.gy>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
15 ---
16 drivers/net/usb/ipheth.c | 2 +-
17 1 file changed, 1 insertion(+), 1 deletion(-)
18
19 --- a/drivers/net/usb/ipheth.c
20 +++ b/drivers/net/usb/ipheth.c
21 @@ -510,8 +510,8 @@ err_register_netdev:
22 ipheth_free_urbs(dev);
23 err_alloc_urbs:
24 err_get_macaddr:
25 -err_alloc_ctrl_buf:
26 kfree(dev->ctrl_buf);
27 +err_alloc_ctrl_buf:
28 err_endpoints:
29 free_netdev(netdev);
30 return retval;