From patchwork Thu Jan 2 22:06:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 234640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DC7EC3276E for ; Thu, 2 Jan 2020 22:43:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 250E120866 for ; Thu, 2 Jan 2020 22:43:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578005017; bh=v+sBa/xxyGzswd17kVX3xJtyhp1J6BAJkLBzf24+sL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=eSy7A8lzUkVh14nGRIYV3RYN7xMZ2UtP2AYYxHzgiEGXT+XXtHe9QXIIpwUgbVJjl rGX4lT6OJ0StkYO8JKadITOEFJt6m120osHKZvi6vO0LBjYRFUEsVJW8+ChYHYo4ar lWJ808Ba7rEcb0KnzllVzYyvi8gvD8V6Rzu6KvA8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728793AbgABWe2 (ORCPT ); Thu, 2 Jan 2020 17:34:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:43004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730553AbgABWe0 (ORCPT ); Thu, 2 Jan 2020 17:34:26 -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 82CFD22314; Thu, 2 Jan 2020 22:34:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004466; bh=v+sBa/xxyGzswd17kVX3xJtyhp1J6BAJkLBzf24+sL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ItnnZFG6aYukOkbjy6zt0w7gBvjZupozQIkCZ9OF8wyX6bnto++xadUZTgHJdsxmp 1UK3gz/TEsWjTVLK2tEG8w8POqNuO6VdCP9Ne4IS0XVsR0kiGxuLhPod3SKlxr982y ycO6NDezT9jX8Mn9FuSHmiS1UfpolLl8IwlVTTn0= 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 4.4 019/137] media: flexcop-usb: fix NULL-ptr deref in flexcop_usb_transfer_init() Date: Thu, 2 Jan 2020 23:06:32 +0100 Message-Id: <20200102220549.256718896@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.618583146@linuxfoundation.org> References: <20200102220546.618583146@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 83d3a5cf272f..932fa31e0624 100644 --- a/drivers/media/usb/b2c2/flexcop-usb.c +++ b/drivers/media/usb/b2c2/flexcop-usb.c @@ -474,7 +474,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.");