Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2334388ybz; Thu, 23 Apr 2020 16:13:41 -0700 (PDT) X-Google-Smtp-Source: APiQypLT7WR3h9mxSbbgfV/6IgMwL2/HjaJ69FG5Pvbpn4zsByb7xuX83DA86SS5mofm5PfTaOVu X-Received: by 2002:a17:906:a418:: with SMTP id l24mr4689806ejz.362.1587683621463; Thu, 23 Apr 2020 16:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587683621; cv=none; d=google.com; s=arc-20160816; b=VvioaSw3YvGlmizyu4T6juD93JG2tJMbZbRMcOavxsn1Bw5BPwGLXK9/C+EJttxvFO KiCco5hI+Oe4gpQ/FQGul2tp8Ll6qtHrMA4mPZv//SwG9b3M8iqhbgni+2lvDnVouHt2 +wPD7ktrMwoSgGbLru0/56N51rO2u4OW/uRtgLm9OTrJaOe6bZ38zqhLADAYHndH9s3r z+5OFE2pRbb6d/o5TXFrbznpMDWRYqes7V1mruD+c/IL1NFZ6nr3ULtjXIcK0tYg/ZJk k3U2h6CTGOLrx2/QSRgYxpvBTFTcqyTF8LzbSvjBbOFE3ZLdmwpeqmkHhZhY3rDIS6+P P0dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=v7A2N6hpPtzbvCF/l8VkwjSuAkciyLoLbOXTpu8USWU=; b=Tewos2dADf7x1my9//sQzS/6L6oDqyArRZrL/TVI+DVKNoYW+00geegB7vtDm9WkAX 4PmYmWY2dV+fqATJQCVXgRC0RVDk9t1m+6mySpIK6rWpNfE2MntoTqf5ck0SBlsT9X9r kyCu49E8ZaXqCE5mySwuO6/jl+Iw4sK8i/s7wQ3eQo548VFuxIYArOau0Wm3KHykdsZN w4QPcgirdM1mnsEm3AppUG1Mwq4U3isPdqLeLMmzMiIe/fh5EI7nnhU6RyZ4WwgwWbVJ iKPXc+qvdrHwmtkPP1PZ8jaXZgltRXeZJMyqoX5drFwc4aB7+P3BJLcvyM2kVUWAs7Yh t4DA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l18si1984401ejb.405.2020.04.23.16.13.17; Thu, 23 Apr 2020 16:13:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727902AbgDWXIz (ORCPT + 99 others); Thu, 23 Apr 2020 19:08:55 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50882 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728653AbgDWXG7 (ORCPT ); Thu, 23 Apr 2020 19:06:59 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvk-0004y2-QY; Fri, 24 Apr 2020 00:06:52 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvg-00E72Z-P0; Fri, 24 Apr 2020 00:06:48 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Hans de Goede" , "Johan Hovold" , "Mauro Carvalho Chehab" , "Hans Verkuil" Date: Fri, 24 Apr 2020 00:07:34 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 227/245] media: ov519: add missing endpoint sanity checks In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit 998912346c0da53a6dbb71fab3a138586b596b30 upstream. Make sure to check that we have at least one endpoint before accessing the endpoint array to avoid dereferencing a NULL-pointer on stream start. Note that these sanity checks are not redundant as the driver is mixing looking up altsettings by index and by number, which need not coincide. Fixes: 1876bb923c98 ("V4L/DVB (12079): gspca_ov519: add support for the ov511 bridge") Fixes: b282d87332f5 ("V4L/DVB (12080): gspca_ov519: Fix ov518+ with OV7620AE (Trust spacecam 320)") Cc: Hans de Goede Signed-off-by: Johan Hovold Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Ben Hutchings --- drivers/media/usb/gspca/ov519.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/media/usb/gspca/ov519.c +++ b/drivers/media/usb/gspca/ov519.c @@ -3497,6 +3497,11 @@ static void ov511_mode_init_regs(struct return; } + if (alt->desc.bNumEndpoints < 1) { + sd->gspca_dev.usb_err = -ENODEV; + return; + } + packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); reg_w(sd, R51x_FIFO_PSIZE, packet_size >> 5); @@ -3622,6 +3627,11 @@ static void ov518_mode_init_regs(struct return; } + if (alt->desc.bNumEndpoints < 1) { + sd->gspca_dev.usb_err = -ENODEV; + return; + } + packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); ov518_reg_w32(sd, R51x_FIFO_PSIZE, packet_size & ~7, 2);