Commit 6bde4c7f authored by Vincent Mailhol's avatar Vincent Mailhol Committed by Marc Kleine-Budde

can: etas_es58x: use devm_kzalloc() to allocate device resources

Replace kzalloc() with devm_kzalloc(). By doing this, we do not need
to care anymore about having to call kfree(). This result in a
simpler and more easy to read code.

Link: https://lore.kernel.org/r/20210628155420.1176217-4-mailhol.vincent@wanadoo.frSigned-off-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 45cb1396
...@@ -2185,7 +2185,8 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf, ...@@ -2185,7 +2185,8 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf,
ops = &es581_4_ops; ops = &es581_4_ops;
} }
es58x_dev = kzalloc(es58x_sizeof_es58x_device(param), GFP_KERNEL); es58x_dev = devm_kzalloc(dev, es58x_sizeof_es58x_device(param),
GFP_KERNEL);
if (!es58x_dev) if (!es58x_dev)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -2235,7 +2236,7 @@ static int es58x_probe(struct usb_interface *intf, ...@@ -2235,7 +2236,7 @@ static int es58x_probe(struct usb_interface *intf,
ret = es58x_get_product_info(es58x_dev); ret = es58x_get_product_info(es58x_dev);
if (ret) if (ret)
goto cleanup_es58x_dev; return ret;
for (ch_idx = 0; ch_idx < es58x_dev->num_can_ch; ch_idx++) { for (ch_idx = 0; ch_idx < es58x_dev->num_can_ch; ch_idx++) {
ret = es58x_init_netdev(es58x_dev, ch_idx); ret = es58x_init_netdev(es58x_dev, ch_idx);
...@@ -2251,8 +2252,6 @@ static int es58x_probe(struct usb_interface *intf, ...@@ -2251,8 +2252,6 @@ static int es58x_probe(struct usb_interface *intf,
unregister_candev(es58x_dev->netdev[ch_idx]); unregister_candev(es58x_dev->netdev[ch_idx]);
free_candev(es58x_dev->netdev[ch_idx]); free_candev(es58x_dev->netdev[ch_idx]);
} }
cleanup_es58x_dev:
kfree(es58x_dev);
return ret; return ret;
} }
...@@ -2283,8 +2282,6 @@ static void es58x_disconnect(struct usb_interface *intf) ...@@ -2283,8 +2282,6 @@ static void es58x_disconnect(struct usb_interface *intf)
} }
es58x_free_urbs(es58x_dev); es58x_free_urbs(es58x_dev);
kfree(es58x_dev);
usb_set_intfdata(intf, NULL); usb_set_intfdata(intf, NULL);
} }
......
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