V4L/DVB (11568): cx18: Fix the handling of i2c bus registration error

* Return actual error values as returned by the i2c subsystem, rather
than 0 or 1.
* If the registration of the second bus fails, unregister the first one
before exiting, otherwise we are leaking resources.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by Jean Delvare and committed by Mauro Carvalho Chehab 272aa396 a357482a

+13 -3
+13 -3
drivers/media/video/cx18/cx18-i2c.c
··· 211 211 /* init + register i2c algo-bit adapter */ 212 212 int init_cx18_i2c(struct cx18 *cx) 213 213 { 214 - int i; 214 + int i, err; 215 215 CX18_DEBUG_I2C("i2c init\n"); 216 216 217 217 for (i = 0; i < 2; i++) { ··· 268 268 cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL, 269 269 core, reset, (u32) CX18_GPIO_RESET_I2C); 270 270 271 - return i2c_bit_add_bus(&cx->i2c_adap[0]) || 272 - i2c_bit_add_bus(&cx->i2c_adap[1]); 271 + err = i2c_bit_add_bus(&cx->i2c_adap[0]); 272 + if (err) 273 + goto err; 274 + err = i2c_bit_add_bus(&cx->i2c_adap[1]); 275 + if (err) 276 + goto err_del_bus_0; 277 + return 0; 278 + 279 + err_del_bus_0: 280 + i2c_del_adapter(&cx->i2c_adap[0]); 281 + err: 282 + return err; 273 283 } 274 284 275 285 void exit_cx18_i2c(struct cx18 *cx)