From: Georgi Valkov Date: Wed, 7 Jun 2023 13:56:59 +0000 (+0200) Subject: usbnet: ipheth: fix risk of NULL pointer deallocation X-Git-Tag: v6.6.17~4555^2~141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2203718c2f59ffdd6c78d54e5add594aebb4461e;p=platform%2Fkernel%2Flinux-rpi.git usbnet: ipheth: fix risk of NULL pointer deallocation 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 Signed-off-by: Foster Snowhill Signed-off-by: David S. Miller --- diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index 6a769df..8875a3d 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -510,8 +510,8 @@ err_register_netdev: 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;