Skip to contentSkip to conversation

media: rzg2l-cru: Fix error pointer dereference

PATCH In review Ethan Tidmore 2 participants 2 messages Feb 17 – Jun 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: rzg2l-cru: Fix error pointer dereference

The function media_pad_remote_pad_unique() can return an error pointer and is not checked. Add check for error pointer.

Detected by Smatch:
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c:414 rzg2l_cru_get_virtual_channel() error:
'remote_pad' dereferencing possible ERR_PTR()

Fixes d7d72dae81d5d ("media: rzg2l-cru: Retrieve virtual channel information")
---
 drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +3 -0
index 162e2ace6931..bf7d96841c78 100644
@@ -411,6 +411,9 @@ static int rzg2l_cru_get_virtual_channel(struct rzg2l_cru_dev *cru)
 	int ret;
 
 	remote_pad = media_pad_remote_pad_unique(&cru->ip.pads[RZG2L_CRU_IP_SINK]);
+	if (IS_ERR(remote_pad))
+		return PTR_ERR(remote_pad);
+
 	ret = v4l2_subdev_call(cru->ip.remote, pad, get_frame_desc, remote_pad->index, &fd);
 	if (ret < 0 && ret != -ENOIOCTLCMD) {
 		dev_err(cru->dev, "get_frame_desc failed on IP remote subdev\n");
Signature · 1 line
2.53.0
maintainer
#1 lore raw

Hi Ethan

Quoted 9 lines · Ethan Tidmore

The function media_pad_remote_pad_unique() can return an error pointer and is not checked. Add check for error pointer.

Detected by Smatch:
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c:414 rzg2l_cru_get_virtual_channel() error:
'remote_pad' dereferencing possible ERR_PTR()

Fixes d7d72dae81d5d ("media: rzg2l-cru: Retrieve virtual channel information")

This really fell into the cracks and you've not been given any feedback. Sorry about this.

Quoted 9 lines
---
 drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +0 -0
index 162e2ace6931..bf7d96841c78 100644

drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c static int rzg2l_cru_get_virtual_channel(struct rzg2l_cru_dev *cru) · line 416

Quoted 6 lines
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +3 -0
@@ -411,6 +411,9 @@ static int rzg2l_cru_get_virtual_channel(struct rzg2l_cru_dev *cru)
 	int ret;
 
 	remote_pad = media_pad_remote_pad_unique(&cru->ip.pads[RZG2L_CRU_IP_SINK]);
+	if (IS_ERR(remote_pad))
+		return PTR_ERR(remote_pad);
+

As far as I can tell the link on the cru->ip sink pad is created with IMMUTABLE flag, so we're sure it always is there.

I don't think the check is required.

Thanks
j

Quoted 7 lines
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +0 -1
 	ret = v4l2_subdev_call(cru->ip.remote, pad, get_frame_desc, remote_pad->index, &fd);
 	if (ret < 0 && ret != -ENOIOCTLCMD) {
 		dev_err(cru->dev, "get_frame_desc failed on IP remote subdev\n");
--

2.53.0