Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp18681619ybl; Fri, 3 Jan 2020 07:04:57 -0800 (PST) X-Google-Smtp-Source: APXvYqyWrcClePVFOBDbLSqA/jmvhsgda33w3B5ORTh71Je282XNJH6gKvT4n4veYTZ9jRVAaecd X-Received: by 2002:a05:6830:4ca:: with SMTP id s10mr59838636otd.268.1578063897540; Fri, 03 Jan 2020 07:04:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578063897; cv=none; d=google.com; s=arc-20160816; b=dvzIHPh4ZBb8kSjs8rEnEHkmvcXUFkzrQwKWIB9zZdIFgQxzhaezrXKG9x5qd/GET+ qZpHxsIMLLa5oRMUDppEO1MoQ/twxrKqar2bhfcmq/szl+njhWCQfbjRaeqOqgKjFodo kyxGF8DDp/WjJqEib4kd3wcYgwfqnUktT71vRbdGX3uXLaA4UGg6F0KF/v6v500uKj5z +YqqqapuK611h89XjTVjyHv/CrSvKriT/ib+xCTiLfMuIcR8MkzN9tgVu7DtbL1Z3buT 2Gyz41R8JpOEjb/HSWNldMq4pEwyKp++bSk0pNqhkYJmIua82TmGhQvRAcUsOVPTtUZP mM2g== 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:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=jYP3oiguXTu4ukRMGsTE94fcOoRU1pxMAUcZzbqTsoQ=; b=QHTXWsSqkznFYZIVkJ+AKYK8BbOOTg2cql0baJb/Gs5AqObuigTNwB6+h7rMDM/X6G +D34VO2mrljnt2AlGd1YmtZr8MheLDJ2UXocsuFA7/7Ui83mQWroSraemoI3EesRHQN9 dJyBdoeujvMmsncXS3s9b5H38swnghG8sJvKIExnb166BmoRhcL618veHqZYP27coESC Pa2yz8qBsi1ukDgcRar+nORkx2RL4S2JFIDxA5DDOnGmStmWuGrtXRNrbBl93q/Je5h8 EciE06o8xSZvIvEJIhL8DCDATeO0xb+1E86dvh8XNhStwx/RSl/4jOE2vXfM8+kpTrBu 1siA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14si33438002otk.225.2020.01.03.07.04.31; Fri, 03 Jan 2020 07:04:57 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727930AbgACPCo (ORCPT + 99 others); Fri, 3 Jan 2020 10:02:44 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39895 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725890AbgACPCo (ORCPT ); Fri, 3 Jan 2020 10:02:44 -0500 Received: by mail-lj1-f193.google.com with SMTP id l2so44145057lja.6; Fri, 03 Jan 2020 07:02:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jYP3oiguXTu4ukRMGsTE94fcOoRU1pxMAUcZzbqTsoQ=; b=kktXjEaeJoDj7MeJeceF+PZIAvZB1dFHWf2rIlpcI78QiDUIEXFx8aqrRtXrAcWClv rFKVKpb5IeEkBo4sjlZ6Yh971Qrxp1ffTFcvLaZsRY5+FTkxX3bqXWaQUxPvjGKyPHc/ C5ir3vqVYaAdV+Q2C+xdKsh9ZsjuRtIJ3h6U1XPoaYjVSAsubhlyeSZA9I6gT63my9+O bQVqw67foi7WGZrwovnhuK7QW6m6q2NUAB18JWvvvapZMhh1/Zh82z9ethsHN3V8k/eV AJO/40nyT+zMsUUgXTZNVN4alPmqpgxlshU4y28PH0pID0iGr+0U5EIb/RL6r1UwZay9 80Eg== X-Gm-Message-State: APjAAAWzn3gWmRS1ySDtjsfw7AXqweyzbrbyGFjC3e197t1XEpYBsI7K gsAP0kBmjriebs/BKUw9pOtMf+ef X-Received: by 2002:a05:651c:118b:: with SMTP id w11mr53364810ljo.54.1578063762042; Fri, 03 Jan 2020 07:02:42 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id t1sm24602951lji.98.2020.01.03.07.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 07:02:40 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1inOTK-0006si-Jb; Fri, 03 Jan 2020 16:02:42 +0100 Date: Fri, 3 Jan 2020 16:02:42 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Yang Yingliang , Sean Young , Mauro Carvalho Chehab , Sasha Levin Subject: Re: [PATCH 5.4 106/434] media: flexcop-usb: fix NULL-ptr deref in flexcop_usb_transfer_init() Message-ID: <20200103150242.GC17614@localhost> References: <20191229172702.393141737@linuxfoundation.org> <20191229172708.658173957@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191229172708.658173957@linuxfoundation.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 29, 2019 at 06:22:39PM +0100, Greg Kroah-Hartman wrote: > From: Yang Yingliang > > [ Upstream commit 649cd16c438f51d4cd777e71ca1f47f6e0c5e65d ] > > If usb_set_interface() failed, iface->cur_altsetting will > not be assigned and it will be used in flexcop_usb_transfer_init() > It may lead a NULL pointer dereference. > > Check usb_set_interface() return value in flexcop_usb_init() > and return failed to avoid using this NULL pointer. > > Signed-off-by: Yang Yingliang > Signed-off-by: Sean Young > Signed-off-by: Mauro Carvalho Chehab > Signed-off-by: Sasha Levin This commit is bogus and should be dropped from all stable queues. Contrary to what the commit message claims, iface->cur_altsetting will never be NULL so there's no risk for a NULL-pointer dereference here. Even though the change itself is benign, we shouldn't spread this confusion further. > --- > drivers/media/usb/b2c2/flexcop-usb.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c > index 1a801dc286f8..d1331f828108 100644 > --- a/drivers/media/usb/b2c2/flexcop-usb.c > +++ b/drivers/media/usb/b2c2/flexcop-usb.c > @@ -504,7 +504,13 @@ urb_error: > static int flexcop_usb_init(struct flexcop_usb *fc_usb) > { > /* use the alternate setting with the larges buffer */ > - usb_set_interface(fc_usb->udev,0,1); > + int ret = usb_set_interface(fc_usb->udev, 0, 1); > + > + if (ret) { > + err("set interface failed."); > + return ret; > + } > + > switch (fc_usb->udev->speed) { > case USB_SPEED_LOW: > err("cannot handle USB speed because it is too slow."); Johan