Skip to content

Commit

Permalink
usbnet: ipheth: fix risk of NULL pointer deallocation
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Georgi Valkov authored and David S. Miller committed Jun 9, 2023
1 parent fd5f4d7 commit 2203718
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/usb/ipheth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2203718

Please sign in to comment.