media: atomisp: mt9m114: Add missing mutex_init() call
authorHans de Goede <hdegoede@redhat.com>
Sun, 13 Oct 2024 15:40:55 +0000 (17:40 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 7 Nov 2024 14:16:06 +0000 (15:16 +0100)
The input_lock was not being initialized, fix this.

Also switch to devm_kzalloc() for the main driver data struct, so that
devm_mutex_init() can be used for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20241013154056.12532-4-hdegoede@redhat.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c

index b0b740dd3ca3ed3d8d8e72e199038a36f9715f87..1a67f93a53d7be6817d1df0db36bd3717cbdb66a 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/acpi.h>
+#include <linux/mutex.h>
 #include "../include/linux/atomisp_gmin_platform.h"
 #include <media/v4l2-device.h>
 
@@ -1527,7 +1528,6 @@ static void mt9m114_remove(struct i2c_client *client)
        v4l2_device_unregister_subdev(sd);
        media_entity_cleanup(&dev->sd.entity);
        v4l2_ctrl_handler_free(&dev->ctrl_handler);
-       kfree(dev);
 }
 
 static int mt9m114_probe(struct i2c_client *client)
@@ -1538,10 +1538,14 @@ static int mt9m114_probe(struct i2c_client *client)
        void *pdata;
 
        /* Setup sensor configuration structure */
-       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+       dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL);
        if (!dev)
                return -ENOMEM;
 
+       ret = devm_mutex_init(&client->dev, &dev->input_lock);
+       if (ret)
+               return ret;
+
        v4l2_i2c_subdev_init(&dev->sd, client, &mt9m114_ops);
        pdata = gmin_camera_platform_data(&dev->sd,
                                          ATOMISP_INPUT_FORMAT_RAW_10,
@@ -1550,14 +1554,12 @@ static int mt9m114_probe(struct i2c_client *client)
                ret = mt9m114_s_config(&dev->sd, client->irq, pdata);
        if (!pdata || ret) {
                v4l2_device_unregister_subdev(&dev->sd);
-               kfree(dev);
                return ret;
        }
 
        ret = atomisp_register_i2c_module(&dev->sd, pdata);
        if (ret) {
                v4l2_device_unregister_subdev(&dev->sd);
-               kfree(dev);
                /* Coverity CID 298095 - return on error */
                return ret;
        }