Commit 20bc8a89 authored by Marc Kleine-Budde's avatar Marc Kleine-Budde Committed by Greg Kroah-Hartman

can: usb_8dev: Fix memory leak of priv->cmd_msg_buffer

commit 7c426313 upstream.

The priv->cmd_msg_buffer is allocated in the probe function, but never
kfree()ed. This patch converts the kzalloc() to resource-managed
kzalloc.
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3584716d
...@@ -954,7 +954,7 @@ static int usb_8dev_probe(struct usb_interface *intf, ...@@ -954,7 +954,7 @@ static int usb_8dev_probe(struct usb_interface *intf,
for (i = 0; i < MAX_TX_URBS; i++) for (i = 0; i < MAX_TX_URBS; i++)
priv->tx_contexts[i].echo_index = MAX_TX_URBS; priv->tx_contexts[i].echo_index = MAX_TX_URBS;
priv->cmd_msg_buffer = kzalloc(sizeof(struct usb_8dev_cmd_msg), priv->cmd_msg_buffer = devm_kzalloc(&intf->dev, sizeof(struct usb_8dev_cmd_msg),
GFP_KERNEL); GFP_KERNEL);
if (!priv->cmd_msg_buffer) if (!priv->cmd_msg_buffer)
goto cleanup_candev; goto cleanup_candev;
...@@ -969,7 +969,7 @@ static int usb_8dev_probe(struct usb_interface *intf, ...@@ -969,7 +969,7 @@ static int usb_8dev_probe(struct usb_interface *intf,
if (err) { if (err) {
netdev_err(netdev, netdev_err(netdev,
"couldn't register CAN device: %d\n", err); "couldn't register CAN device: %d\n", err);
goto cleanup_cmd_msg_buffer; goto cleanup_candev;
} }
err = usb_8dev_cmd_version(priv, &version); err = usb_8dev_cmd_version(priv, &version);
...@@ -990,9 +990,6 @@ static int usb_8dev_probe(struct usb_interface *intf, ...@@ -990,9 +990,6 @@ static int usb_8dev_probe(struct usb_interface *intf,
cleanup_unregister_candev: cleanup_unregister_candev:
unregister_netdev(priv->netdev); unregister_netdev(priv->netdev);
cleanup_cmd_msg_buffer:
kfree(priv->cmd_msg_buffer);
cleanup_candev: cleanup_candev:
free_candev(netdev); free_candev(netdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment