media: malic55: Fix possible ERR_PTR deference in enable_streams
Subsystems (2)
PATCH 1/1 media: malic55: Fix possible ERR_PTR deference in enable_streams
The media_pad_remote_pad_unique() function returns either a valid pointer or an ERR_PTR() on failure (-ENOTUNIQ if multiple links are enabled, -ENOLINK if no connected pad is found). The return value was assigned directly to isp->remote_src and dereferenced in the next line without checking for errors, which could lead to an ERR_PTR dereference.
Add proper error checking with IS_ERR() before dereferencing the pointer. Also set isp->remote_src to NULL on error to maintain consistency with other error paths in the function.
--- drivers/media/platform/arm/mali-c55/mali-c55-isp.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/platform/arm/mali-c55/mali-c55-isp.c +7 -0
@@ -360,6 +360,13 @@ static int mali_c55_isp_enable_streams(struct v4l2_subdev *sd, sink_pad = &isp->pads[MALI_C55_ISP_PAD_SINK_VIDEO ]; isp->remote_src =media_pad_remote_pad_unique (sink_pad); +if (IS_ERR (isp->remote_src)) { + ret =PTR_ERR (isp->remote_src); +dev_err (mali_c55->dev,"Failed to get remote source pad: %d\n" , ret); + isp->remote_src =NULL ; +return ret; + } + src_sd =media_entity_to_v4l2_subdev (isp->remote_src->entity); isp->frame_sequence =0 ;
Signature · 1 line
2.43.0
Hi Alper
Quoted 7 lines · Alper Ak
The
media_pad_remote_pad_unique()function returns either a valid pointer or anERR_PTR()on failure (-ENOTUNIQif multiple links are enabled,-ENOLINKif no connected pad is found). The return value was assigned directly toisp->remote_srcand dereferenced in the next line without checking for errors, which could lead to anERR_PTRdereference.
Quoted 6 lines
Add proper error checking with
IS_ERR()before dereferencing the pointer. Also setisp->remote_srcto NULL on error to maintain consistency with other error paths in the function.Fixes d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")Signed-off-by Alper Ak <[email protected]>
As the media link on the ISP sink pad #0 can connect to either the TPG entity or to the [CSI-2 RX | IVC] pair, it is created without an IMMUTABLE flag and can be in facts disabled.
So I guess the check is correct in this case:
As per the other patch for the CRU, it might be nice to attribute credit to the static analysis tool you have used.
Quoted 25 lines
--- drivers/media/platform/arm/mali-c55/mali-c55-isp.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/media/platform/arm/mali-c55/mali-c55-isp.c +7
-1@@ -360,6 +360,13 @@ static int mali_c55_isp_enable_streams(struct v4l2_subdev *sd, sink_pad = &isp->pads[MALI_C55_ISP_PAD_SINK_VIDEO ]; isp->remote_src =media_pad_remote_pad_unique (sink_pad); +if (IS_ERR (isp->remote_src)) { + ret =PTR_ERR (isp->remote_src); +dev_err (mali_c55->dev,"Failed to get remote source pad: %d\n" , ret); + isp->remote_src =NULL ; +return ret; + } + src_sd =media_entity_to_v4l2_subdev (isp->remote_src->entity); isp->frame_sequence =0 ; --2.43.0
Morning Alper, thanks for the patch
Quoted 22 lines · Alper Ak
The
media_pad_remote_pad_unique()function returns either a valid pointer or anERR_PTR()on failure (-ENOTUNIQif multiple links are enabled,-ENOLINKif no connected pad is found). The return value was assigned directly toisp->remote_srcand dereferenced in the next line without checking for errors, which could lead to anERR_PTRdereference.Add proper error checking with
IS_ERR()before dereferencing the pointer. Also setisp->remote_srcto NULL on error to maintain consistency with other error paths in the function.Fixes d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")Signed-off-by Alper Ak <[email protected]>--- drivers/media/platform/arm/mali-c55/mali-c55-isp.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/media/platform/arm/mali-c55/mali-c55-isp.c +0
-0
drivers/media/platform/arm/mali-c55/mali-c55-isp.c static int mali_c55_isp_enable_streams(struct v4l2_subdev *sd, · line 369
Quoted 10 lines
drivers/media/platform/arm/mali-c55/mali-c55-isp.c +7
-0@@ -360,6 +360,13 @@ static int mali_c55_isp_enable_streams(struct v4l2_subdev *sd, sink_pad = &isp->pads[MALI_C55_ISP_PAD_SINK_VIDEO ]; isp->remote_src =media_pad_remote_pad_unique (sink_pad); +if (IS_ERR (isp->remote_src)) { + ret =PTR_ERR (isp->remote_src); +dev_err (mali_c55->dev,"Failed to get remote source pad: %d\n" , ret); + isp->remote_src =NULL ; +return ret; + } +
Quoted 3 lines
drivers/media/platform/arm/mali-c55/mali-c55-isp.c +0
-0src_sd =media_entity_to_v4l2_subdev (isp->remote_src->entity); isp->frame_sequence =0 ;
…
Quoted 1 line
pointer or an
ERR_PTR()on failure …
error pointer
Quoted 3 lines
Add proper error checking with
IS_ERR()before dereferencing the pointer. Also setisp->remote_srcto NULL on error to maintain consistency with other error paths in the function.
…
* See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v6.19#n34
* Were any source code analysis tools involved here?
* Would a summary phrase like “Prevent error pointer dereference in mali_c55_isp_enable_streams()” be more appropriate?
Regards,
Markus
Hello everyone, look like this patch hasn't been applied. Did I miss something I needed to do to get it applied? If there is anything I need to do, please let me know.
Markus Elfring <[email protected]>, 14 Şub 2026 Cmt, 17:37 tarihinde şunu yazdı:
Quoted 24 lines
…
Quoted 1 line
pointer or an
ERR_PTR()on failure …error pointer
Quoted 3 lines
Add proper error checking with
IS_ERR()before dereferencing the pointer. Also setisp->remote_srcto NULL on error to maintain consistency with other error paths in the function.…
* See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v6.19#n34* Were any source code analysis tools involved here?
* Would a summary phrase like “Prevent error pointer dereference in mali_c55_isp_enable_streams()” be more appropriate?
Regards,
Markus
Quoted 3 lines
Hello everyone, look like this patch hasn't been applied. Did I miss something I needed to do to get it applied? If there is anything I need to do, please let me know.
Did anything hinder you to take also my patch review comments better into account?
Regards,
Markus
Jacopo Mondi
maintainerHi Alper,
Quoted 3 lines · Alper Ak
Hello everyone, look like this patch hasn't been applied. Did I miss something I needed to do to get it applied? If there is anything I need to do, please let me know.
No, I think it's good.
The only think I see is my comment
As per the other patch for the CRU, it might be nice to attribute credit to the static analysis tool you have used.
which makes me think there was a discussion on another patch about the tool.
If you wish to resend to add credit, you're welcome to do so.
Otherwise, patches are collected in the media tree before the current -rc6 (usually) so seat back and relax it might still take a while.
Quoted 28 lines
Markus Elfring <[email protected]>, 14 Şub 2026 Cmt, 17:37 tarihinde şunu yazdı:
Quoted 24 lines
…
Quoted 1 line
pointer or an
ERR_PTR()on failure …error pointer
Quoted 3 lines
Add proper error checking with
IS_ERR()before dereferencing the pointer. Also setisp->remote_srcto NULL on error to maintain consistency with other error paths in the function.…
* See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v6.19#n34* Were any source code analysis tools involved here?
* Would a summary phrase like “Prevent error pointer dereference in mali_c55_isp_enable_streams()” be more appropriate?
Regards,
Markus
Quoted 5 lines
Quoted 3 lines
Hello everyone, look like this patch hasn't been applied. Did I miss something I needed to do to get it applied? If there is anything I need to do, please let me know.
No, I think it's good.
Does such feedback indicate that you would tolerate typos here?
Quoted 6 lines
The only think I see is my comment
As per the other patch for the CRU, it might be nice to attribute credit to the static analysis tool you have used.
which makes me think there was a discussion on another patch about the tool.
Will such patch review concerns be reconsidered any more?
Regards,
Markus