提交 a2bbf5d0 编写于 作者: M Markus Elfring 提交者: Mauro Carvalho Chehab

[media] DVB: Less function calls in dvb_ca_en50221_init() after error detection

The functions "dvb_unregister_device" and "kfree" could still be called
by the dvb_ca_en50221_init() function in the case that a previous resource
allocation failed.

* Corresponding details could be improved by adjustments for jump targets.

* Let us delete also an unnecessary check for the variable "ca" there.
Signed-off-by: NMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: NMauro Carvalho Chehab <mchehab@osg.samsung.com>
上级 07d0e554
...@@ -1678,14 +1678,14 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, ...@@ -1678,14 +1678,14 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
/* initialise the system data */ /* initialise the system data */
if ((ca = kzalloc(sizeof(struct dvb_ca_private), GFP_KERNEL)) == NULL) { if ((ca = kzalloc(sizeof(struct dvb_ca_private), GFP_KERNEL)) == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto exit;
} }
ca->pub = pubca; ca->pub = pubca;
ca->flags = flags; ca->flags = flags;
ca->slot_count = slot_count; ca->slot_count = slot_count;
if ((ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot), GFP_KERNEL)) == NULL) { if ((ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot), GFP_KERNEL)) == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto free_ca;
} }
init_waitqueue_head(&ca->wait_queue); init_waitqueue_head(&ca->wait_queue);
ca->open = 0; ca->open = 0;
...@@ -1696,7 +1696,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, ...@@ -1696,7 +1696,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
/* register the DVB device */ /* register the DVB device */
ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca, DVB_DEVICE_CA); ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca, DVB_DEVICE_CA);
if (ret) if (ret)
goto error; goto free_slot_info;
/* now initialise each slot */ /* now initialise each slot */
for (i = 0; i < slot_count; i++) { for (i = 0; i < slot_count; i++) {
...@@ -1711,7 +1711,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, ...@@ -1711,7 +1711,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
if (signal_pending(current)) { if (signal_pending(current)) {
ret = -EINTR; ret = -EINTR;
goto error; goto unregister_device;
} }
mb(); mb();
...@@ -1722,16 +1722,17 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, ...@@ -1722,16 +1722,17 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
ret = PTR_ERR(ca->thread); ret = PTR_ERR(ca->thread);
printk("dvb_ca_init: failed to start kernel_thread (%d)\n", printk("dvb_ca_init: failed to start kernel_thread (%d)\n",
ret); ret);
goto error; goto unregister_device;
} }
return 0; return 0;
error: unregister_device:
if (ca != NULL) { dvb_unregister_device(ca->dvbdev);
dvb_unregister_device(ca->dvbdev); free_slot_info:
kfree(ca->slot_info); kfree(ca->slot_info);
kfree(ca); free_ca:
} kfree(ca);
exit:
pubca->private = NULL; pubca->private = NULL;
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册