Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3289778ybb; Tue, 31 Mar 2020 02:11:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv85KJUd3BmfWuVLOtlJ+ROLmC5AC0NpHKc4irMZ5hUvBmO5VkyVzSB2OhHgnUyofH4d/G/ X-Received: by 2002:aca:682:: with SMTP id 124mr1400175oig.69.1585645913464; Tue, 31 Mar 2020 02:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645913; cv=none; d=google.com; s=arc-20160816; b=iPqCeK5rDx3aRDpcTgEnbEDB3+vzwwVPScuCh4fa58RzeDcB64YY2k+jFyskDyP3YV 9aS0lcAuUFE+rWxDZ4KRzhu4bt079deZtyxv68n4yxJ0DhjsJhZuY7jNWWcB0Ot2LSZo HVGux2iXioXCaC1N40Kea5Rnv62pjhw6MyopHDLoC+rSg5u9zJZV5A1i9ccaMqXpbPVt ajAqy440ccob8i3XG6mD8Q/yycddOuGrf2oTq7gO33BYiDs8nRcQLt/Ev6OOhFRq4yPD 6BkKv4tBj7hdzkedOUzG5QXn1FviPhNqfUZHB1QIuu6hh/u0kzi5KNAi3KEN+a9zAoQ+ jLXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SKeykMpypjb4oTJTgg3h5xDdIzZ26k5P1992sIKQhbA=; b=PvZ1yZO2UHcejzTUttWA5m4QmUyhwqBwXtX8SO3WMnlSftWDrrZ5GWq7Jj7EVNllxw DU2AgqRRtgUlmNqvckovzLRqiuhRmJhIGGBe/sQx27NOfOZNIKyIrceKsFuUKKS8JWwU EmgwmLcmcJT7kh9l/i+4v4JWMO3NBPZex8WKAyVM3WTscAEGOPCiRkn48ULh9JmY69rG fOjge4MDO9ji7WUSWFkc3tojAVn5H9ctQMomeeqZO8xh1f0XePaSorojsutRTCRn/aWo u8yHz6eAMwmuOObC0piPUOxyUBt1+wFLKsrWbrB/W+aCHmA2tJPKzWoCgQbDtENNqhS7 NFBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bo3D1KVP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si7672190oom.72.2020.03.31.02.11.41; Tue, 31 Mar 2020 02:11:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bo3D1KVP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731534AbgCaJJx (ORCPT + 99 others); Tue, 31 Mar 2020 05:09:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:53312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731524AbgCaJJw (ORCPT ); Tue, 31 Mar 2020 05:09:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7712620675; Tue, 31 Mar 2020 09:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645791; bh=vhGI45rn2Ty8tXWcSB2nbLy+mTD6PsHxSUVxyGrjF3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bo3D1KVPqrX2wzyVcuuml82Dq+pOAA6udcaAEu3bDGrVM+iadaSLkaNe3EJIA7Est v1wRNGyoN26dMAUAz3qSlHwMcEfLmtD5mRhlmW3aOUenB3l1JMZlBPbW1BfpNMU7+L 3z0SsxkJLxH6dWz4rGvBuU5AaY3Ux3C0pQ3faaBU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Johan Hovold , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.5 166/170] media: ov519: add missing endpoint sanity checks Date: Tue, 31 Mar 2020 10:59:40 +0200 Message-Id: <20200331085440.324888272@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: stable # 2.6.31 Cc: Hans de Goede Signed-off-by: Johan Hovold Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- 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 @@ -3477,6 +3477,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); @@ -3603,6 +3608,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);