diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2015-04-04 02:16:01 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-05-01 12:50:54 +0200 |
commit | 90ca75fd1945d9e51e21cbde0aae1aad68730dc5 (patch) | |
tree | 3726bc1c49c1b33839621e4ea1e4f964b324f99f /drivers/media/platform/marvell-ccic | |
parent | [media] marvell-ccic: fix V4L2_PIX_FMT_SBGGR8 support (diff) | |
download | linux-90ca75fd1945d9e51e21cbde0aae1aad68730dc5.tar.xz linux-90ca75fd1945d9e51e21cbde0aae1aad68730dc5.zip |
[media] marvell-ccic: fix memory leak on failure path in cafe_smbus_setup()
If i2c_add_adapter() fails, adap is not deallocated.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/platform/marvell-ccic')
-rw-r--r-- | drivers/media/platform/marvell-ccic/cafe-driver.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c b/drivers/media/platform/marvell-ccic/cafe-driver.c index e857405b46fd..77890bd0deab 100644 --- a/drivers/media/platform/marvell-ccic/cafe-driver.c +++ b/drivers/media/platform/marvell-ccic/cafe-driver.c @@ -339,17 +339,21 @@ static int cafe_smbus_setup(struct cafe_camera *cam) adap = kzalloc(sizeof(*adap), GFP_KERNEL); if (adap == NULL) return -ENOMEM; - cam->mcam.i2c_adapter = adap; - cafe_smbus_enable_irq(cam); adap->owner = THIS_MODULE; adap->algo = &cafe_smbus_algo; strcpy(adap->name, "cafe_ccic"); adap->dev.parent = &cam->pdev->dev; i2c_set_adapdata(adap, cam); ret = i2c_add_adapter(adap); - if (ret) + if (ret) { printk(KERN_ERR "Unable to register cafe i2c adapter\n"); - return ret; + kfree(adap); + return ret; + } + + cam->mcam.i2c_adapter = adap; + cafe_smbus_enable_irq(cam); + return 0; } static void cafe_smbus_shutdown(struct cafe_camera *cam) |