Message ID | 57fca5dbcb8e157371deeba019eba430bf7148b2.1715935535.git.cy_huang@richtek.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: v4l: async: Fix NULL pointer dereference in adding ancillary links | expand |
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.
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