Commit b2624ff4 authored by Silvan Jegen's avatar Silvan Jegen Committed by Mauro Carvalho Chehab

[media] mantis: fix error handling

Remove dead code, make goto label names more expressive and add a label
in order to call mantis_dvb_exit if mantis_uart_init fails.

Also make sure that mantis_pci_exit is called if we fail the
mantis_stream_control call and that we call mantis_i2c_exit if
mantis_get_mac fails.

[mchehab@osg.samsung.com: fix merge conflict]
Signed-off-by: default avatarSilvan Jegen <s.jegen@gmail.com>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 44767fc4
...@@ -169,8 +169,7 @@ static int mantis_pci_probe(struct pci_dev *pdev, ...@@ -169,8 +169,7 @@ static int mantis_pci_probe(struct pci_dev *pdev,
mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL); mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
if (mantis == NULL) { if (mantis == NULL) {
printk(KERN_ERR "%s ERROR: Out of memory\n", __func__); printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
err = -ENOMEM; return -ENOMEM;
goto fail0;
} }
mantis->num = devs; mantis->num = devs;
...@@ -183,67 +182,64 @@ static int mantis_pci_probe(struct pci_dev *pdev, ...@@ -183,67 +182,64 @@ static int mantis_pci_probe(struct pci_dev *pdev,
err = mantis_pci_init(mantis); err = mantis_pci_init(mantis);
if (err) { if (err) {
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err); dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err);
goto fail1; goto err_free_mantis;
} }
err = mantis_stream_control(mantis, STREAM_TO_HIF); err = mantis_stream_control(mantis, STREAM_TO_HIF);
if (err < 0) { if (err < 0) {
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err); dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err);
goto fail1; goto err_pci_exit;
} }
err = mantis_i2c_init(mantis); err = mantis_i2c_init(mantis);
if (err < 0) { if (err < 0) {
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err); dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err);
goto fail2; goto err_pci_exit;
} }
err = mantis_get_mac(mantis); err = mantis_get_mac(mantis);
if (err < 0) { if (err < 0) {
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err); dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err);
goto fail2; goto err_i2c_exit;
} }
err = mantis_dma_init(mantis); err = mantis_dma_init(mantis);
if (err < 0) { if (err < 0) {
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err); dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err);
goto fail3; goto err_i2c_exit;
} }
err = mantis_dvb_init(mantis); err = mantis_dvb_init(mantis);
if (err < 0) { if (err < 0) {
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err); dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
goto fail4; goto err_dma_exit;
} }
err = mantis_uart_init(mantis); err = mantis_uart_init(mantis);
if (err < 0) { if (err < 0) {
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization failed <%d>", err); dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization failed <%d>", err);
goto fail6; goto err_dvb_exit;
} }
devs++; devs++;
return err; return 0;
err_dvb_exit:
mantis_dvb_exit(mantis);
fail6: err_dma_exit:
fail4:
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err);
mantis_dma_exit(mantis); mantis_dma_exit(mantis);
fail3: err_i2c_exit:
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err);
mantis_i2c_exit(mantis); mantis_i2c_exit(mantis);
fail2: err_pci_exit:
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err);
mantis_pci_exit(mantis); mantis_pci_exit(mantis);
fail1: err_free_mantis:
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err);
kfree(mantis); kfree(mantis);
fail0:
return err; return err;
} }
......
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