From patchwork Mon Mar 13 12:53:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9620777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3227E60522 for ; Mon, 13 Mar 2017 12:55:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 231762848B for ; Mon, 13 Mar 2017 12:55:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17C1C28497; Mon, 13 Mar 2017 12:55:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AADF728495 for ; Mon, 13 Mar 2017 12:55:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752337AbdCMMzK (ORCPT ); Mon, 13 Mar 2017 08:55:10 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36578 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750929AbdCMMyg (ORCPT ); Mon, 13 Mar 2017 08:54:36 -0400 Received: by mail-lf0-f66.google.com with SMTP id g70so11735232lfh.3; Mon, 13 Mar 2017 05:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Dmv/qVFfqQoRDghu0tqVOaeDAtj9d8duhJNVI5vWYMA=; b=itsxiJYX9x7qtUV94WB2HOFFIdSZU+m3DC7ewjLMzltS9mbG8nIjaXD8OE1+udKTV/ fYHYEge9WXOB+SsxgN5kc9OHp+7n3WpA/2oCB5E52uDpgMqXpUGSwPVIkhbgSYQKlWk6 lCos6f/ryiNzyRFDbRIEBP3i5dXG4iUUw0Z1R0I42FdFWeUeWetufBVjmbHzutMxul7C ZuR2YIHtHOLzezHsWLQEqFjePmJar8hfiIdzqwZUdpfwaqA5cfd2bgRlI/PvTDS2da1A FsIor5WKQinOl1sNIRi25jOIcv3gNHJw1u6A9RLPw/m9V3hTyPQYpg0YB5Y7HlDP/bSM tIBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Dmv/qVFfqQoRDghu0tqVOaeDAtj9d8duhJNVI5vWYMA=; b=pFE5Pge01VMvrR2y3KAp27ATdQY+pDsigzWBaTPjI6TkkVLdyOs5oU8ACW8sZaA0HV v6XasHA7dH8V/g8B2FamZllQW1kazqrGCce9FNa1KYyGAxfT5zI7F+DbfHkVa3xJg6In 8XCgEqRyrC6EOXMuBE5YslqwuCm4P4Dt3217GXv6NQ7RZqu62dPSSC0XhiXacJLjn+PH TrZxf2kNklWvG+MvSSCWBJKa07RSq/zGdbsY8JTyXrRMbFVaSd8f8i+fnMZOSUyrI6vW N7NQmNDdhzmqW2tGkKlADg74IJ6RmZeDECuCrsgGSZUcKFKoG7d1PgUusYqjG4mvVbG7 TkGA== X-Gm-Message-State: AMke39nKsnZw0lj8UnkSfnBSCMX3LTVpujVeApgVLM1MEN0BQDAYR7OzzJQw+AkTS5Fj4A== X-Received: by 10.25.196.8 with SMTP id u8mr7971697lff.21.1489409674117; Mon, 13 Mar 2017 05:54:34 -0700 (PDT) Received: from xi.terra ([84.216.234.102]) by smtp.gmail.com with ESMTPSA id p27sm3707529lfg.5.2017.03.13.05.54.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Mar 2017 05:54:31 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1cnPUU-0007fL-Ez; Mon, 13 Mar 2017 13:54:22 +0100 From: Johan Hovold To: Mauro Carvalho Chehab Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable , Hans de Goede Subject: [PATCH 6/6] [media] gspca: konica: add missing endpoint sanity check Date: Mon, 13 Mar 2017 13:53:59 +0100 Message-Id: <20170313125359.29394-7-johan@kernel.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170313125359.29394-1-johan@kernel.org> References: <20170313125359.29394-1-johan@kernel.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 # 2.6.37 Cc: Hans de Goede Signed-off-by: Johan Hovold --- 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;