Skip to content

Commit f1472cb

Browse files
wenwenwang1davem330
authored andcommitted
net: kalmia: fix memory leaks
In kalmia_init_and_get_ethernet_addr(), 'usb_buf' is allocated through kmalloc(). In the following execution, if the 'status' returned by kalmia_send_init_packet() is not 0, 'usb_buf' is not deallocated, leading to memory leaks. To fix this issue, add the 'out' label to free 'usb_buf'. Signed-off-by: Wenwen Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1eca92e commit f1472cb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/net/usb/kalmia.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,16 @@ kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr)
113113
status = kalmia_send_init_packet(dev, usb_buf, ARRAY_SIZE(init_msg_1),
114114
usb_buf, 24);
115115
if (status != 0)
116-
return status;
116+
goto out;
117117

118118
memcpy(usb_buf, init_msg_2, 12);
119119
status = kalmia_send_init_packet(dev, usb_buf, ARRAY_SIZE(init_msg_2),
120120
usb_buf, 28);
121121
if (status != 0)
122-
return status;
122+
goto out;
123123

124124
memcpy(ethernet_addr, usb_buf + 10, ETH_ALEN);
125-
125+
out:
126126
kfree(usb_buf);
127127
return status;
128128
}

0 commit comments

Comments
 (0)