Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13365638ybl; Sun, 29 Dec 2019 10:10:39 -0800 (PST) X-Google-Smtp-Source: APXvYqzj33Ncv7/RmhWzbs9Js6lD4lZfgIcF8JVdooJPNAP18n6SipopYcESCeqcrFM39seOJpF9 X-Received: by 2002:a05:6830:1715:: with SMTP id 21mr25001441otk.145.1577643039336; Sun, 29 Dec 2019 10:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577643039; cv=none; d=google.com; s=arc-20160816; b=FmUA3eCPvm2+TJb5jtSRIpTRU+UU4nCytKkGLIyYr/k7n6wWGk9UYJl7lKpN0dPvr/ YTM0PXjtO06XDOwvAQvSd3KPR8bHF6IU7YjiwDkKVoK/SfFdPkWysJw9j3wgyZCFwmbc C4wuvWt6ZUvByfhkc6IE+SCH5aaP4Uro3AlkLfLY3Gq9uJBQOFzBPf5h6VuwEaOan0P2 cyNcgEKSKJxejzABd9Mfc7SnkPQ1McTjlnntTmHclHo5RpHTyrszBo9TKew3BS6kd8xb VI3Vrwzf2s5IxCRpEFXr25PSmkM8NB8rRFHN9ldIABM26vDJlPbk944b2MvhRiZB6e0e e1+Q== 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=AYkVVt+MXN8zyEyjp5MsIVQYPFoJtGN2Qpd+F09MrxY=; b=r+lu3TH+W2MtFN17lQMve5AHJkIVQoebAnDY6Wg1UyUsUup1QEZytu4XSVrQYmun0W 5j5VWqjMarv18BFiJIkWWmCDjWPFPc/TLuZdHgRSWs5aWxxLppUCNKgBqk7eGgAHw8fg WW7zBjE2JAoOqbIIctnrYSDbY4YMZIbSP4R0T5wdM1tE/DOu22hQwtJCGW2FX9FoanUl HAh9bjbksY/jnFbYbMaKS8XceGnMQ59WG+LGFvDVa/HpjX4RaKHIM8FD187/wmPg9cew Xc4GBXN633pcgQ691vCCDYIhh5xYu3jVL2tW2wE1w5xsXAsrhCfpwhSFQL2IZxYlK6uP kF/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=18F5hFlc; 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 t25si10979012oth.246.2019.12.29.10.10.27; Sun, 29 Dec 2019 10:10:39 -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; dkim=pass header.i=@kernel.org header.s=default header.b=18F5hFlc; 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 S1731826AbfL2SI2 (ORCPT + 99 others); Sun, 29 Dec 2019 13:08:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:57570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731204AbfL2RrK (ORCPT ); Sun, 29 Dec 2019 12:47:10 -0500 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 DF764206A4; Sun, 29 Dec 2019 17:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641629; bh=FV/Pmj9ObJekWwE3LH4eF9xL+9DjPRKOWUrNL6WwKPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=18F5hFlcUAYwM91MOkBpnF6BzSYAHF6BBGG0s6OfyqlZg8hOjjvhCQJQqImSGXKRl wnPP7s8h9eheSTEwioogeFDvfn3LSIosuZiQZPnQyZqjIhj7hGNl+VeYlhi+TUY7wZ cc1mUgyTgYTQ+egKrcdvwXPHgwYVTTY/hi7ntM6o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Sean Young , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 106/434] media: flexcop-usb: fix NULL-ptr deref in flexcop_usb_transfer_init() Date: Sun, 29 Dec 2019 18:22:39 +0100 Message-Id: <20191229172708.658173957@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@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: 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 --- 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."); -- 2.20.1