Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <gvalkov@gmail.com>
Signed-off-by: Foster Snowhill <forst@pen.gy>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Georgi Valkov and committed by
David S. Miller
2203718c fd5f4d7d

+1 -1
+1 -1
drivers/net/usb/ipheth.c
··· 510 510 ipheth_free_urbs(dev); 511 511 err_alloc_urbs: 512 512 err_get_macaddr: 513 - err_alloc_ctrl_buf: 514 513 kfree(dev->ctrl_buf); 514 + err_alloc_ctrl_buf: 515 515 err_endpoints: 516 516 free_netdev(netdev); 517 517 return retval;