* [PATCH] media: v4l: async: Fix NULL pointer dereference in adding ancillary links
@ 2024-05-17 8:51 cy_huang
2024-05-17 9:03 ` ChiYuan Huang
0 siblings, 1 reply; 2+ messages in thread
From: cy_huang @ 2024-05-17 8:51 UTC (permalink / raw)
To: Sakari Ailus, Mauro Carvalho Chehab
Cc: Daniel Scally, Laurent Pinchart, Jean-Michel Hautbois,
linux-media, linux-kernel, ChiYuan Huang
From: ChiYuan Huang <cy_huang@richtek.com>
In v4l2_async_create_ancillary_links(), ancillary links are created for
lens and flash sub-devices. These are sub-device to sub-device links and if
the async notifier is related to a V4L2 device, the source sub-device of
the ancillary link is NULL, leading to a NULL pointer dereference. Check
the notifier's sd field is non-NULL in v4l2_async_create_ancillary_links().
Fixes: aa4faf6eb271 ("media: v4l2-async: Create links during v4l2_async_match_notify()")
Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
Hi:
Following the comment to revise the patch title and commit message.
The previous patch discussion is at the below link.
https://lore.kernel.org/lkml/e2f9f2b7b7de956d70b8567a2ab285409fff988b.1715136478.git.cy_huang@richtek.com/
---
drivers/media/v4l2-core/v4l2-async.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index 3ec323bd528b..9d3161c51954 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -324,6 +324,9 @@ static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n,
sd->entity.function != MEDIA_ENT_F_FLASH)
return 0;
+ if (!n->sd)
+ return 0;
+
link = media_create_ancillary_link(&n->sd->entity, &sd->entity);
#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] media: v4l: async: Fix NULL pointer dereference in adding ancillary links
2024-05-17 8:51 [PATCH] media: v4l: async: Fix NULL pointer dereference in adding ancillary links cy_huang
@ 2024-05-17 9:03 ` ChiYuan Huang
0 siblings, 0 replies; 2+ messages in thread
From: ChiYuan Huang @ 2024-05-17 9:03 UTC (permalink / raw)
To: Sakari Ailus, Mauro Carvalho Chehab
Cc: Daniel Scally, Laurent Pinchart, Jean-Michel Hautbois,
linux-media, linux-kernel
On Fri, May 17, 2024 at 04:51:29PM +0800, cy_huang@richtek.com wrote:
> From: ChiYuan Huang <cy_huang@richtek.com>
>
> In v4l2_async_create_ancillary_links(), ancillary links are created for
> lens and flash sub-devices. These are sub-device to sub-device links and if
> the async notifier is related to a V4L2 device, the source sub-device of
> the ancillary link is NULL, leading to a NULL pointer dereference. Check
> the notifier's sd field is non-NULL in v4l2_async_create_ancillary_links().
Not seeing the message 'No send the v2 patch'. Please ignore this one.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-17 9:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-17 8:51 [PATCH] media: v4l: async: Fix NULL pointer dereference in adding ancillary links cy_huang
2024-05-17 9:03 ` ChiYuan Huang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.