aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2015-03-23 12:25:53 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-05-12 07:12:18 -0400
commitb2624ff4bf46869df66148b2e1e675981565742e (patch)
tree4c7a1fb37feb13fb5e9a708e98ace9f9d9765291
parent44767fc418b6f69f629f70033eb7a08de396224e (diff)
[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: Silvan Jegen <s.jegen@gmail.com> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/pci/mantis/mantis_cards.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/drivers/media/pci/mantis/mantis_cards.c b/drivers/media/pci/mantis/mantis_cards.c
index f437646aa9aa..9861a8cf1dce 100644
--- a/drivers/media/pci/mantis/mantis_cards.c
+++ b/drivers/media/pci/mantis/mantis_cards.c
@@ -169,8 +169,7 @@ static int mantis_pci_probe(struct pci_dev *pdev,
169 mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL); 169 mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
170 if (mantis == NULL) { 170 if (mantis == NULL) {
171 printk(KERN_ERR "%s ERROR: Out of memory\n", __func__); 171 printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
172 err = -ENOMEM; 172 return -ENOMEM;
173 goto fail0;
174 } 173 }
175 174
176 mantis->num = devs; 175 mantis->num = devs;
@@ -183,67 +182,64 @@ static int mantis_pci_probe(struct pci_dev *pdev,
183 err = mantis_pci_init(mantis); 182 err = mantis_pci_init(mantis);
184 if (err) { 183 if (err) {
185 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err); 184 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err);
186 goto fail1; 185 goto err_free_mantis;
187 } 186 }
188 187
189 err = mantis_stream_control(mantis, STREAM_TO_HIF); 188 err = mantis_stream_control(mantis, STREAM_TO_HIF);
190 if (err < 0) { 189 if (err < 0) {
191 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err); 190 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err);
192 goto fail1; 191 goto err_pci_exit;
193 } 192 }
194 193
195 err = mantis_i2c_init(mantis); 194 err = mantis_i2c_init(mantis);
196 if (err < 0) { 195 if (err < 0) {
197 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err); 196 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err);
198 goto fail2; 197 goto err_pci_exit;
199 } 198 }
200 199
201 err = mantis_get_mac(mantis); 200 err = mantis_get_mac(mantis);
202 if (err < 0) { 201 if (err < 0) {
203 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err); 202 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err);
204 goto fail2; 203 goto err_i2c_exit;
205 } 204 }
206 205
207 err = mantis_dma_init(mantis); 206 err = mantis_dma_init(mantis);
208 if (err < 0) { 207 if (err < 0) {
209 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err); 208 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err);
210 goto fail3; 209 goto err_i2c_exit;
211 } 210 }
212 211
213 err = mantis_dvb_init(mantis); 212 err = mantis_dvb_init(mantis);
214 if (err < 0) { 213 if (err < 0) {
215 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err); 214 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
216 goto fail4; 215 goto err_dma_exit;
217 } 216 }
217
218 err = mantis_uart_init(mantis); 218 err = mantis_uart_init(mantis);
219 if (err < 0) { 219 if (err < 0) {
220 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization failed <%d>", err); 220 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization failed <%d>", err);
221 goto fail6; 221 goto err_dvb_exit;
222 } 222 }
223 223
224 devs++; 224 devs++;
225 225
226 return err; 226 return 0;
227 227
228err_dvb_exit:
229 mantis_dvb_exit(mantis);
228 230
229fail6: 231err_dma_exit:
230fail4:
231 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err);
232 mantis_dma_exit(mantis); 232 mantis_dma_exit(mantis);
233 233
234fail3: 234err_i2c_exit:
235 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err);
236 mantis_i2c_exit(mantis); 235 mantis_i2c_exit(mantis);
237 236
238fail2: 237err_pci_exit:
239 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err);
240 mantis_pci_exit(mantis); 238 mantis_pci_exit(mantis);
241 239
242fail1: 240err_free_mantis:
243 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err);
244 kfree(mantis); 241 kfree(mantis);
245 242
246fail0:
247 return err; 243 return err;
248} 244}
249 245