Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1599331

[PATCH 6/6] [media] gspca: konica: add missing endpoint sanity check

From Johan Hovold <johan@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 6/6] [media] gspca: konica: add missing endpoint sanity check
Date 2017-03-13 14:00 +0100
Message-ID <tkxJU-Fd-35@gated-at.bofh.it> (permalink)
References <tkxJT-Fd-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Make sure to check the number of endpoints to avoid accessing memory
beyond the endpoint array should a device lack the expected endpoints.

Note that, as far as I can tell, the gspca framework has already made
sure there is at least one endpoint in the current alternate setting so
there should be no risk for a NULL-pointer dereference here.

Fixes: b517af722860 ("V4L/DVB: gspca_konica: New gspca subdriver for
konica chipset using cams")
Cc: stable <stable@vger.kernel.org>     # 2.6.37
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/media/usb/gspca/konica.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/usb/gspca/konica.c b/drivers/media/usb/gspca/konica.c
index 71f273377f83..31b2117e8f1d 100644
--- a/drivers/media/usb/gspca/konica.c
+++ b/drivers/media/usb/gspca/konica.c
@@ -184,6 +184,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
 		return -EIO;
 	}
 
+	if (alt->desc.bNumEndpoints < 2)
+		return -ENODEV;
+
 	packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
 
 	n = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
-- 
2.12.0

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] [media] fix missing endpoint sanity checks Johan Hovold <johan@kernel.org> - 2017-03-13 14:00 +0100
  [PATCH 3/6] [media] cx231xx-cards: fix NULL-deref at probe Johan Hovold <johan@kernel.org> - 2017-03-13 14:00 +0100
  [PATCH 4/6] [media] cx231xx-audio: fix init error path Johan Hovold <johan@kernel.org> - 2017-03-13 14:00 +0100
  [PATCH 5/6] [media] cx231xx-audio: fix NULL-deref at probe Johan Hovold <johan@kernel.org> - 2017-03-13 14:00 +0100
  [PATCH 2/6] [media] usbvision: fix NULL-deref at probe Johan Hovold <johan@kernel.org> - 2017-03-13 14:00 +0100
  [PATCH 1/6] [media] dib0700: fix NULL-deref at probe Johan Hovold <johan@kernel.org> - 2017-03-13 14:00 +0100
  [PATCH 6/6] [media] gspca: konica: add missing endpoint sanity check Johan Hovold <johan@kernel.org> - 2017-03-13 14:00 +0100

csiph-web