Patch "media: ov5640: Fix a memory leak when ov5640_probe fails" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    media: ov5640: Fix a memory leak when ov5640_probe fails

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     media-ov5640-fix-a-memory-leak-when-ov5640_probe-fai.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2950f51a872ac9b4eb663fe583cf2c84ff730829
Author: Xiaolei Wang <xiaolei.wang@xxxxxxxxxxxxx>
Date:   Mon Aug 7 17:05:35 2023 +0800

    media: ov5640: Fix a memory leak when ov5640_probe fails
    
    [ Upstream commit 20290feaaeb76cc719921aad275ccb18662a7c3a ]
    
    sensor->ctrls.handler is initialized in ov5640_init_controls(),
    so when the sensor is not connected and ov5640_sensor_resume()
    fails, sensor->ctrls.handler should be released, otherwise a
    memory leak will be detected:
    
    unreferenced object 0xc674ca80 (size 64):
       comm "swapper/0", pid 1, jiffies 4294938337 (age 204.880s)
       hex dump (first 32 bytes):
         80 55 75 c6 80 54 75 c6 00 55 75 c6 80 52 75 c6 .Uu..Tu..Uu..Ru.
         00 53 75 c6 00 00 00 00 00 00 00 00 00 00 00 00 .Su..........
    
    Fixes: 85644a9b37ec ("media: ov5640: Use runtime PM")
    Signed-off-by: Xiaolei Wang <xiaolei.wang@xxxxxxxxxxxxx>
    Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 7c041dafff2b1..8d6cdc7c345b0 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -3928,7 +3928,7 @@ static int ov5640_probe(struct i2c_client *client)
 	ret = ov5640_sensor_resume(dev);
 	if (ret) {
 		dev_err(dev, "failed to power on\n");
-		goto entity_cleanup;
+		goto free_ctrls;
 	}
 
 	pm_runtime_set_active(dev);
@@ -3953,8 +3953,9 @@ static int ov5640_probe(struct i2c_client *client)
 err_pm_runtime:
 	pm_runtime_put_noidle(dev);
 	pm_runtime_disable(dev);
-	v4l2_ctrl_handler_free(&sensor->ctrls.handler);
 	ov5640_sensor_suspend(dev);
+free_ctrls:
+	v4l2_ctrl_handler_free(&sensor->ctrls.handler);
 entity_cleanup:
 	media_entity_cleanup(&sensor->sd.entity);
 	mutex_destroy(&sensor->lock);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux