media: marvell-ccic: set error code in probe
authorEvgeny Novikov <novikov@ispras.ru>
Wed, 26 May 2021 14:35:06 +0000 (16:35 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 17 Jun 2021 08:21:24 +0000 (10:21 +0200)
When i2c_new_client_device() fails, cafe_pci_probe() cleans up all
resources and returns 0. The patch sets the error code on the
corresponding path.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/marvell-ccic/cafe-driver.c

index baac86f..9aa374f 100644 (file)
@@ -486,6 +486,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
        struct cafe_camera *cam;
        struct mcam_camera *mcam;
        struct v4l2_async_subdev *asd;
+       struct i2c_client *i2c_dev;
 
        /*
         * Start putting together one of our big camera structures.
@@ -561,11 +562,16 @@ static int cafe_pci_probe(struct pci_dev *pdev,
        clkdev_create(mcam->mclk, "xclk", "%d-%04x",
                i2c_adapter_id(cam->i2c_adapter), ov7670_info.addr);
 
-       if (!IS_ERR(i2c_new_client_device(cam->i2c_adapter, &ov7670_info))) {
-               cam->registered = 1;
-               return 0;
+       i2c_dev = i2c_new_client_device(cam->i2c_adapter, &ov7670_info);
+       if (IS_ERR(i2c_dev)) {
+               ret = PTR_ERR(i2c_dev);
+               goto out_mccic_shutdown;
        }
 
+       cam->registered = 1;
+       return 0;
+
+out_mccic_shutdown:
        mccic_shutdown(mcam);
 out_smbus_shutdown:
        cafe_smbus_shutdown(cam);