Skip to contentSkip to conversation

media: i2c: ov5648: Free V4L2 fwnode data on unbind

PATCH Superseded Rafael Mendonca 4 participants 6 messages Sep 19, 2022 – Sep 20, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: i2c: ov5648: Free V4L2 fwnode data on unbind

The V4L2 fwnode data structure doesn't get freed on unbind, which leads to a memleak.

Fixes e43ccb0a045f ("media: i2c: Add support for the OV5648 image sensor")
---
 drivers/media/i2c/ov5648.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/ov5648.c +2 -0
index dfcd33e9ee13..95850f06112b 100644
@@ -2598,6 +2598,8 @@ static int ov5648_remove(struct i2c_client *client)
 	mutex_destroy(&sensor->mutex);
 	media_entity_cleanup(&subdev->entity);
 
+	v4l2_fwnode_endpoint_free(&sensor->endpoint);
+
 	return 0;
 }
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Rafael,

Quoted 25 lines · Rafael Mendonca

The V4L2 fwnode data structure doesn't get freed on unbind, which leads to a memleak.

Fixes e43ccb0a045f ("media: i2c: Add support for the OV5648 image sensor")
---
 drivers/media/i2c/ov5648.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/ov5648.c +2 -0
index dfcd33e9ee13..95850f06112b 100644
@@ -2598,6 +2598,8 @@ static int ov5648_remove(struct i2c_client *client)
 	mutex_destroy(&sensor->mutex);
 	media_entity_cleanup(&subdev->entity);
 
+	v4l2_fwnode_endpoint_free(&sensor->endpoint);
+
 	return 0;
 }
 
Signature · 1 line
2.34.1

Looks good to me.

Regards,
Tommaso

Signature · 10 lines
Tommaso Merciai
Embedded Linux Engineer
[email protected]
__________________________________

Amarula Solutions SRL
Via Le Canevare 30, 31100 Treviso, Veneto, IT
T. +39 042 243 5310
[email protected]
www.amarulasolutions.com
#2 lore raw
In reply to Rafael Mendonca

Hi Rafael

Quoted 14 lines · Rafael Mendonca

The V4L2 fwnode data structure doesn't get freed on unbind, which leads to a memleak.

Fixes e43ccb0a045f ("media: i2c: Add support for the OV5648 image sensor")
---
 drivers/media/i2c/ov5648.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/ov5648.c +0 -0
index dfcd33e9ee13..95850f06112b 100644

drivers/media/i2c/ov5648.c static int ov5648_remove(struct i2c_client *client) · line 2602

Quoted 5 lines
drivers/media/i2c/ov5648.c +2 -0
@@ -2598,6 +2598,8 @@ static int ov5648_remove(struct i2c_client *client)
 	mutex_destroy(&sensor->mutex);
 	media_entity_cleanup(&subdev->entity);
 
+	v4l2_fwnode_endpoint_free(&sensor->endpoint);
+

Nit: all the other function calls are in a single block, this one doesn't deserve an empty line before it.

Nit apart, the patch is a good fix.

Quoted 6 lines
drivers/media/i2c/ov5648.c +0 -1
 	return 0;
 }
 
--

2.34.1

Reviewed-by on v1 1/1
#3 lore raw
In reply to Rafael Mendonca

Hi Rafael,

Quoted 2 lines · Rafael Mendonca

The V4L2 fwnode data structure doesn't get freed on unbind, which leads to a memleak.

Thanks for this patch, good catch!

I agree with Jacopo, you shouldn't add a newline before the call. Feel free to send a v2 with that fixed and include my:

Cheers,

Paul

Quoted 22 lines
Fixes e43ccb0a045f ("media: i2c: Add support for the OV5648 image sensor")
---
 drivers/media/i2c/ov5648.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/ov5648.c +2 -0
index dfcd33e9ee13..95850f06112b 100644
@@ -2598,6 +2598,8 @@ static int ov5648_remove(struct i2c_client *client)
 	mutex_destroy(&sensor->mutex);
 	media_entity_cleanup(&subdev->entity);
 
+	v4l2_fwnode_endpoint_free(&sensor->endpoint);
+
 	return 0;
 }
 
Signature · 1 line
2.34.1
Signature · 3 lines
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#4 lore raw
Quoted 9 lines · Paul Kocialkowski

Hi Rafael,

Quoted 2 lines · Rafael Mendonca

The V4L2 fwnode data structure doesn't get freed on unbind, which leads to a memleak.

Thanks for this patch, good catch!

I agree with Jacopo, you shouldn't add a newline before the call.

Thanks for the review, I'll send a v2. As the code for the ov5648 is similar to the ov8865, and in the 8865 there is this blank line before the v4l2_fwnode_endpoint_free() call, I thought it might be good to keep the same style here, that's why this empty line ended up appearing here.

Quoted 35 lines

Feel free to send a v2 with that fixed and include my:

Cheers,

Paul

Quoted 22 lines
Fixes e43ccb0a045f ("media: i2c: Add support for the OV5648 image sensor")
---
 drivers/media/i2c/ov5648.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/ov5648.c +2 -0
index dfcd33e9ee13..95850f06112b 100644
@@ -2598,6 +2598,8 @@ static int ov5648_remove(struct i2c_client *client)
 	mutex_destroy(&sensor->mutex);
 	media_entity_cleanup(&subdev->entity);
 
+	v4l2_fwnode_endpoint_free(&sensor->endpoint);
+
 	return 0;
 }
 
Signature · 1 line
2.34.1
Signature · 3 lines
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#5 lore raw

Hi Rafael,

Quoted 7 lines · Rafael Mendonca
Quoted 6 lines · Paul Kocialkowski

Hi Rafael,

Quoted 2 lines · Rafael Mendonca

The V4L2 fwnode data structure doesn't get freed on unbind, which leads to a memleak.

Quoted 8 lines
Quoted 3 lines

Thanks for this patch, good catch!

I agree with Jacopo, you shouldn't add a newline before the call.

Thanks for the review, I'll send a v2. As the code for the ov5648 is similar to the ov8865, and in the 8865 there is this blank line before the v4l2_fwnode_endpoint_free() call, I thought it might be good to keep the same style here, that's why this empty line ended up appearing here.

Understood! I'd be tempted to make a cosmetic fix for 8865 but will probably wait to group it with functional changes.

Cheers,

Paul

Quoted 37 lines
Quoted 35 lines

Feel free to send a v2 with that fixed and include my:

Cheers,

Paul

Quoted 22 lines
Fixes e43ccb0a045f ("media: i2c: Add support for the OV5648 image sensor")
---
 drivers/media/i2c/ov5648.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/i2c/ov5648.c +2 -0
index dfcd33e9ee13..95850f06112b 100644
@@ -2598,6 +2598,8 @@ static int ov5648_remove(struct i2c_client *client)
 	mutex_destroy(&sensor->mutex);
 	media_entity_cleanup(&subdev->entity);
 
+	v4l2_fwnode_endpoint_free(&sensor->endpoint);
+
 	return 0;
 }
 
Signature · 1 line
2.34.1
Signature · 3 lines
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
Signature · 3 lines
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com