All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: linux-usb@vger.kernel.org
Cc: balbi@kernel.org, laurent.pinchart@ideasonboard.com,
	paul.elder@ideasonboard.com, kernel@pengutronix.de
Subject: [PATCH v4 3/7] usb: gadget: uvc: prevent index variables to start from 0
Date: Sun,  5 Dec 2021 23:57:59 +0100	[thread overview]
Message-ID: <20211205225803.268492-4-m.grzeschik@pengutronix.de> (raw)
In-Reply-To: <20211205225803.268492-1-m.grzeschik@pengutronix.de>

Some configfs variables like bDefaultFrameIndex are always starting by
1. This patch adds a check to prevent setting those variables to 0.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

---
v1 -> v2: -
v2 -> v3: -
v3 -> v4: -

 drivers/usb/gadget/function/uvc_configfs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c
index 77d64031aa9c2a..b6bb5706299951 100644
--- a/drivers/usb/gadget/function/uvc_configfs.c
+++ b/drivers/usb/gadget/function/uvc_configfs.c
@@ -1565,6 +1565,12 @@ uvcg_uncompressed_##cname##_store(struct config_item *item,		\
 	if (ret)							\
 		goto end;						\
 									\
+	/* index values in uvc are never 0 */				\
+	if (!num) {							\
+		ret = -EINVAL;						\
+		goto end;						\
+	}								\
+									\
 	u->desc.aname = num;						\
 	ret = len;							\
 end:									\
@@ -1758,6 +1764,12 @@ uvcg_mjpeg_##cname##_store(struct config_item *item,			\
 	if (ret)							\
 		goto end;						\
 									\
+	/* index values in uvc are never 0 */				\
+	if (!num) {							\
+		ret = -EINVAL;						\
+		goto end;						\
+	}								\
+									\
 	u->desc.aname = num;						\
 	ret = len;							\
 end:									\
-- 
2.30.2


  parent reply	other threads:[~2021-12-05 22:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-05 22:57 [PATCH v4 0/7] usb: gadget: uvc: use configfs entries for negotiation and v4l2 VIDIOCS Michael Grzeschik
2021-12-05 22:57 ` [PATCH v4 1/7] media: v4l: move helper functions for fractions from uvc to v4l2-common Michael Grzeschik
2021-12-05 22:57 ` [PATCH v4 2/7] media: uvcvideo: move uvc_format_desc to common header Michael Grzeschik
2021-12-05 22:57 ` Michael Grzeschik [this message]
2021-12-05 22:58 ` [PATCH v4 4/7] usb: gadget: uvc: move structs " Michael Grzeschik
2021-12-05 22:58 ` [PATCH v4 5/7] usb: gadget: uvc: track frames in format entries Michael Grzeschik
2021-12-05 22:58 ` [PATCH v4 6/7] usb: gadget: uvc: add VIDIOC function Michael Grzeschik
2021-12-06 11:31   ` kernel test robot
2021-12-06 11:31     ` kernel test robot
2021-12-05 22:58 ` [PATCH v4 7/7] usb: gadget: uvc: add format/frame handling code Michael Grzeschik
2021-12-06 10:30   ` kernel test robot
2021-12-06 10:30     ` kernel test robot
2021-12-06 14:04   ` kernel test robot
2021-12-06 14:04     ` kernel test robot

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=20211205225803.268492-4-m.grzeschik@pengutronix.de \
    --to=m.grzeschik@pengutronix.de \
    --cc=balbi@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=paul.elder@ideasonboard.com \
    /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.