Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3288842ybb; Tue, 31 Mar 2020 02:10:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv2vAe/xw6in0ilIRqCMh91apW8PLw1czpHiHzYuG/GR1nU4Cju2+rFrUk1GkVSq6hl5IW9 X-Received: by 2002:aca:310a:: with SMTP id x10mr1301263oix.151.1585645842341; Tue, 31 Mar 2020 02:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645842; cv=none; d=google.com; s=arc-20160816; b=l6L0nebqgD2f82ECZIXTPZ/osNMg/j+iIqhsRkfFHUqh7A6cqFBxvWf1IuTSQFM6Hs pe+9IKciNIxXuhd+ItgvxOSCNmnTx8D1NfoqAeYNdlHGaDPNxCUgDcbX9TBLJrDjQ9g2 47f90VoJ8D1+LDOAg81vrGH7hTNl2jAfJieIgATp7OTWEe6CRkW27ZAXe+Resgw4M0OJ 1WgFE2/H3IhjOypwOzeFjp81trpADrK9kf4+Ge+/PvRuGEYhVsCIT6B4xi3QwXE1HbmY 85Xbq5CjscwZEH5AVekK0GT4IiDRzItQ3NUYSnXLHDRX97DDfvCdqswbmATRSwCDO3xN 2joQ== 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=k9A6o80rEdpk1xb5UhTjL6tlilhLXzKioVSs7MUKbXk=; b=bfrHieeAR/22N3qkyzGRJUBVbFPqi5fY361ocA6pVRyZSeg/XTVI+UusBUK9zNqQSq aNNWVaU5ZYI4xDkm29Wmfp6z6y5/eFkcXr4T/uftX4lyKIYXMCaeqytwfrIOny9PK9lp 10wk/M1JWKbaDXYvIB5HkaWJzURET3czS9h7+x1NMm5fnykRxf1TFjYf9Tg4TCgzT4/D nqSoHGpZbhQ6T6SGiKXceCYxCjSgI5TnplntL5WsliB7XO1euJAsCvHZrZ+KxdmPNjkw nVWy4dnZ0okMAdtGQHJUMGHLnZPsunvxzg97vHxwX6NPF7CD3pBVHfMa7JmNptqqZA1k GsAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="0Sq/CyxH"; 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 141si6642605oii.44.2020.03.31.02.10.30; Tue, 31 Mar 2020 02:10:42 -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="0Sq/CyxH"; 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 S1731526AbgCaJKK (ORCPT + 99 others); Tue, 31 Mar 2020 05:10:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:53718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731174AbgCaJKI (ORCPT ); Tue, 31 Mar 2020 05:10:08 -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 31ED42072E; Tue, 31 Mar 2020 09:10:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645806; bh=DF2vG2JENOKeJQt1F4AhXFxKkI4NDkRA7YESUG6WUw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Sq/CyxHs2SW9Bgl4FeNMopcj+qoR8oA1GR5fEWN3Bt7nkSNzMrjivZPWjVVu1kaY lVpCZ9g0mDG+TCm0RLMQ2SBWgJgOkIYterrn7gKkdT/LAl3WhEflZmYhQ5tt50stNr 0v2OblOfskGfZQRIihvCAc4qIyeOwDOhoiW4ZRtU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , Johan Hovold , Sean Young , Mauro Carvalho Chehab Subject: [PATCH 5.5 155/170] media: flexcop-usb: fix endpoint sanity check Date: Tue, 31 Mar 2020 10:59:29 +0200 Message-Id: <20200331085439.486016511@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 bca243b1ce0e46be26f7c63b5591dfbb41f558e5 upstream. commit 1b976fc6d684 ("media: b2c2-flexcop-usb: add sanity checking") added an endpoint sanity check to address a NULL-pointer dereference on probe. Unfortunately the check was done on the current altsetting which was later changed. Fix this by moving the sanity check to after the altsetting is changed. Fixes: 1b976fc6d684 ("media: b2c2-flexcop-usb: add sanity checking") Cc: Oliver Neukum Cc: stable Signed-off-by: Johan Hovold Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/b2c2/flexcop-usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/media/usb/b2c2/flexcop-usb.c +++ b/drivers/media/usb/b2c2/flexcop-usb.c @@ -511,6 +511,9 @@ static int flexcop_usb_init(struct flexc return ret; } + if (fc_usb->uintf->cur_altsetting->desc.bNumEndpoints < 1) + return -ENODEV; + switch (fc_usb->udev->speed) { case USB_SPEED_LOW: err("cannot handle USB speed because it is too slow."); @@ -544,9 +547,6 @@ static int flexcop_usb_probe(struct usb_ struct flexcop_device *fc = NULL; int ret; - if (intf->cur_altsetting->desc.bNumEndpoints < 1) - return -ENODEV; - if ((fc = flexcop_device_kmalloc(sizeof(struct flexcop_usb))) == NULL) { err("out of memory\n"); return -ENOMEM;