All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Ricardo Ribalda <ribalda@chromium.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] media: uvcvideo: fix a crash in uvc_ctrl_init_ctrl()
Date: Tue, 19 Jul 2022 16:45:29 +0300	[thread overview]
Message-ID: <Yta1eXgbVFGrVuTJ@kili> (raw)

There is a path where "mapping" is NULL when we try to process the
common mappings so it will crash.

Fixes: 86f7ef773156 ("media: uvcvideo: Add support for per-device control mapping overrides")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This bug was previously reported by the kbuild bot and fixed in later
versions of the patchset.  The git log doesn't have a link to
lore.kernel.org but I suspect an earlier version got merged?

 drivers/media/usb/uvc/uvc_ctrl.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index e4826a846861..00ea894e79fd 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -2413,9 +2413,9 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain,
 {
 	const struct uvc_control_info *info = uvc_ctrls;
 	const struct uvc_control_info *iend = info + ARRAY_SIZE(uvc_ctrls);
-	const struct uvc_control_mapping *mapping = uvc_ctrl_mappings;
-	const struct uvc_control_mapping *mend =
-		mapping + ARRAY_SIZE(uvc_ctrl_mappings);
+	const struct uvc_control_mapping *mapping;
+	const struct uvc_control_mapping *mend;
+	unsigned int i;
 
 	/*
 	 * XU controls initialization requires querying the device for control
@@ -2453,7 +2453,6 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain,
 	 */
 	if (chain->dev->info->mappings) {
 		bool custom = false;
-		unsigned int i;
 
 		for (i = 0; (mapping = chain->dev->info->mappings[i]); ++i) {
 			if (uvc_entity_match_guid(ctrl->entity, mapping->entity) &&
@@ -2468,7 +2467,8 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain,
 	}
 
 	/* Process common mappings next. */
-	for (; mapping < mend; ++mapping) {
+	for (i = 0; i < ARRAY_SIZE(uvc_ctrl_mappings); i++) {
+		mapping = &uvc_ctrl_mappings[i];
 		if (uvc_entity_match_guid(ctrl->entity, mapping->entity) &&
 		    ctrl->info.selector == mapping->selector)
 			__uvc_ctrl_add_mapping(chain, ctrl, mapping);
-- 
2.35.1


             reply	other threads:[~2022-07-19 14:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19 13:45 Dan Carpenter [this message]
2022-07-19 22:34 ` [PATCH] media: uvcvideo: fix a crash in uvc_ctrl_init_ctrl() Laurent Pinchart
2022-07-20  9:20   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yta1eXgbVFGrVuTJ@kili \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ribalda@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.