drivers/net/rpmsgdrv.c: Improve init error handling

Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
This commit is contained in:
Jani Paalijarvi 2023-09-20 08:16:29 +03:00 committed by Xiang Xiao
parent 999970b820
commit c8540a1f9b
1 changed files with 17 additions and 1 deletions

View File

@ -1145,14 +1145,30 @@ int net_rpmsg_drv_init(FAR const char *cpuname,
/* Register the device with the openamp */ /* Register the device with the openamp */
rpmsg_register_callback(dev, ret = rpmsg_register_callback(dev,
net_rpmsg_drv_device_created, net_rpmsg_drv_device_created,
net_rpmsg_drv_device_destroy, net_rpmsg_drv_device_destroy,
NULL, NULL,
NULL); NULL);
if (ret < 0)
{
kmm_free(priv);
return ret;
}
/* Register the device with the OS so that socket IOCTLs can be performed */ /* Register the device with the OS so that socket IOCTLs can be performed */
ret = netdev_register(dev, lltype); ret = netdev_register(dev, lltype);
if (ret < 0)
{
rpmsg_unregister_callback(dev,
net_rpmsg_drv_device_created,
net_rpmsg_drv_device_destroy,
NULL,
NULL);
kmm_free(priv);
}
return ret; return ret;
} }