Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1335099imm; Tue, 2 Oct 2018 06:42:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV60aLuP+MFryIMFVacLxqu2bRAWv+4WOO/egpp5y+w4/RV9IEtx7CyM3dwl6xII5/7ArBESD X-Received: by 2002:a17:902:a03:: with SMTP id 3-v6mr16902589plo.323.1538487757346; Tue, 02 Oct 2018 06:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538487757; cv=none; d=google.com; s=arc-20160816; b=KcUG2NZuVMDaEk/XdMqZIoEFvCyFFhbrGPKkFKFldJKUVzFNL2iUBi7wHwptFT8WcW wzzWSt2VFGapkDnpYdo4x4oUrimTdgBX+7d4kivPprzd48y86ok6QuLFzYl3zdxh5Xn2 l2UqHnd47PxPyy0PVa0ZlBpfYFu8OhhUIU2l+wQAF/uYVIbJujPLO4KUfRhusTrfX6ca VHd93jETuv3mAMKmndVt3z0oSHDfpO/NCOV5QiJicd+1mS1mT/DCgHTloD3RPJEUq6pn ZhD0XIyIXnKGo1pcUDfszkvDHbyg8h5J6HC+t0/Von0sT4GdVlnhhLGpeah5jYwRvdRD P+fw== 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; bh=H3ATptnr79gXCmHDBgRYZXJJvtXwEzWSFLzUryXe6KE=; b=VympImdiOMDbniGskqt++xnouxWPZ3mIFL2PPTPLq+ApYGR27YgdoF0ZUFw8qplu0I 8jA8dy/U/9AYcxTVvjcjjPrkBqDNZ6AUC517ObPsSoUdTobRiomu+F9PtyC2irH78Wdc 8en1nZFDq++nKoixd+fOJ5OdVOFYiDL07uFWZxWm9TOC+XfqV5ZFjEZgCvc3Ww2pkamR B8F1MGAv4wxobC6BO9ntGpenmpjaqZYCk4Y1p6h78pFcVee6bzB1T7sffmZZjQcT9dWL pOidTLnmF+eMVawEE/+8+FQBuysy5J84XCA0BCvpeeCLW7WaRNjiMy1B7HBKYQpKEh8H jXNA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5-v6si16043721pll.414.2018.10.02.06.42.21; Tue, 02 Oct 2018 06:42:37 -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; 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 S1732878AbeJBUXm (ORCPT + 99 others); Tue, 2 Oct 2018 16:23:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36340 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731713AbeJBUUA (ORCPT ); Tue, 2 Oct 2018 16:20:00 -0400 Received: from localhost (24-104-73-23-ip-static.hfc.comcastbusiness.net [24.104.73.23]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E816EC4D; Tue, 2 Oct 2018 13:36:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , syzbot+19c3aaef85a89d451eac@syzkaller.appspotmail.com Subject: [PATCH 4.9 65/94] USB: handle NULL config in usb_find_alt_setting() Date: Tue, 2 Oct 2018 06:25:19 -0700 Message-Id: <20181002132505.010262771@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132500.494838053@linuxfoundation.org> References: <20181002132500.494838053@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alan Stern commit c9a4cb204e9eb7fa7dfbe3f7d3a674fa530aa193 upstream. usb_find_alt_setting() takes a pointer to a struct usb_host_config as an argument; it searches for an interface with specified interface and alternate setting numbers in that config. However, it crashes if the usb_host_config pointer argument is NULL. Since this is a general-purpose routine, available for use in many places, we want to to be more robust. This patch makes it return NULL whenever the config argument is NULL. Signed-off-by: Alan Stern Reported-by: syzbot+19c3aaef85a89d451eac@syzkaller.appspotmail.com CC: Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/usb.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -91,6 +91,8 @@ struct usb_host_interface *usb_find_alt_ struct usb_interface_cache *intf_cache = NULL; int i; + if (!config) + return NULL; for (i = 0; i < config->desc.bNumInterfaces; i++) { if (config->intf_cache[i]->altsetting[0].desc.bInterfaceNumber == iface_num) {