From patchwork Mon Dec 16 17:48:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 11294933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 204C014B7 for ; Mon, 16 Dec 2019 18:15:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F1D97206E0 for ; Mon, 16 Dec 2019 18:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576520152; bh=cMLkqMqK+Gd4sTCmmglswR0S3qcdjkuJPxkvMp7nKAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=yMXcqbOevSl3b+jctvX4ALBYlZf3XbA1hg1Euj8W+aQIH8HOWKVnj/m+CbqS8TBaK IxoxgCvR7WvcDd8hWRl+7oYDGtCpQqjJs247oNTJdBUn/9rN1MU2OOsGHaYANKxW1e 3okVX/V0PTDJOsHl7Avd5i46xEisGb+gCdbLd0ok= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731436AbfLPSPu (ORCPT ); Mon, 16 Dec 2019 13:15:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:37438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731246AbfLPSPu (ORCPT ); Mon, 16 Dec 2019 13:15:50 -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 120F5206E0; Mon, 16 Dec 2019 18:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576520149; bh=cMLkqMqK+Gd4sTCmmglswR0S3qcdjkuJPxkvMp7nKAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ke3O/pJu31RCt55oNfkcrDhor6nPp7OADwpDQmK6gLfjxzl8tzXS1q4oUA8aJH5wI u/10IjgWH1mLlH6UaCRaT5vVuGMWE/L2PatSGBKkP0teRQ3sNwaMPljzAfzSx9gRvE rfWmBDgNR6yAgod+KwONj1Eun21RyQixD13Ncp9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chunfeng Yun , Nagarjuna Kristam , Linus Walleij , linux-usb@vger.kernel.org, Bryan ODonoghue Subject: [PATCH 5.4 035/177] usb: common: usb-conn-gpio: Dont log an error on probe deferral Date: Mon, 16 Dec 2019 18:48:11 +0100 Message-Id: <20191216174828.552457581@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174811.158424118@linuxfoundation.org> References: <20191216174811.158424118@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Bryan O'Donoghue commit 59120962e4be4f72be537adb17da6881c4b3797c upstream. This patch makes the printout of the error message for failing to get a VBUS regulator handle conditional on the error code being something other than -EPROBE_DEFER. Deferral is a normal thing, we don't need an error message for this. Cc: Chunfeng Yun Cc: Nagarjuna Kristam Cc: Linus Walleij Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: Bryan O'Donoghue Cc: stable Link: https://lore.kernel.org/r/20191128134358.3880498-2-bryan.odonoghue@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/common/usb-conn-gpio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/common/usb-conn-gpio.c +++ b/drivers/usb/common/usb-conn-gpio.c @@ -156,7 +156,8 @@ static int usb_conn_probe(struct platfor info->vbus = devm_regulator_get(dev, "vbus"); if (IS_ERR(info->vbus)) { - dev_err(dev, "failed to get vbus\n"); + if (PTR_ERR(info->vbus) != -EPROBE_DEFER) + dev_err(dev, "failed to get vbus\n"); return PTR_ERR(info->vbus); } From patchwork Mon Dec 16 17:48:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 11294937 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3FD1138D for ; Mon, 16 Dec 2019 18:18:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1BC424655 for ; Mon, 16 Dec 2019 18:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576520280; bh=Yg1EZxh1vdL3Nuet+CAmg4++HU631afGWtZUgpRty20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dJknDPHLXhpznWOU70mWy1pvsiWtWmCTEYABV+aICqtoDBjXP1xB3NyR1buznJLKr HjpovY/JwIYPiyqXHW7FyFJjKPOGpsBnWl8SjuFvlmLYMVLKlj0LifV3E8hk+YysnZ 40KCtwAj8MurAZhn3TdC3oeKXvkPy2ekW1a0xD1c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731727AbfLPSR7 (ORCPT ); Mon, 16 Dec 2019 13:17:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:42556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731368AbfLPSRy (ORCPT ); Mon, 16 Dec 2019 13:17:54 -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 97C1920717; Mon, 16 Dec 2019 18:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576520274; bh=Yg1EZxh1vdL3Nuet+CAmg4++HU631afGWtZUgpRty20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fmi5J+lYRpUBGOYbDV/hkhxz5HXw/wnh3o9yJVU3YBk4DBPf1a8DBblRB+apvxULE hQCTqCxxGTD+HNN4l5UQK/YMbqD0AaNPdnPZzTwVQAMkvym5mJjC8krCyflRq2Wacy o/Y72P8WpTugZ+XaJETAhbS4L1uVN20LRk9zdeTo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , Heikki Krogerus , Peter Chen , Hans de Goede , Chunfeng Yun , Suzuki K Poulose , linux-usb@vger.kernel.org Subject: [PATCH 5.4 047/177] usb: roles: fix a potential use after free Date: Mon, 16 Dec 2019 18:48:23 +0100 Message-Id: <20191216174830.065264932@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174811.158424118@linuxfoundation.org> References: <20191216174811.158424118@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Wen Yang commit 1848a543191ae32e558bb0a5974ae7c38ebd86fc upstream. Free the sw structure only after we are done using it. This patch just moves the put_device() down a bit to avoid the use after free. Fixes: 5c54fcac9a9d ("usb: roles: Take care of driver module reference counting") Signed-off-by: Wen Yang Reviewed-by: Heikki Krogerus Reviewed-by: Peter Chen Cc: stable Cc: Hans de Goede Cc: Chunfeng Yun Cc: Suzuki K Poulose Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20191124142236.25671-1-wenyang@linux.alibaba.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/roles/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -169,8 +169,8 @@ EXPORT_SYMBOL_GPL(fwnode_usb_role_switch void usb_role_switch_put(struct usb_role_switch *sw) { if (!IS_ERR_OR_NULL(sw)) { - put_device(&sw->dev); module_put(sw->dev.parent->driver->owner); + put_device(&sw->dev); } } EXPORT_SYMBOL_GPL(usb_role_switch_put); From patchwork Mon Dec 16 17:48:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 11294935 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF25714B7 for ; Mon, 16 Dec 2019 18:17:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCC9021582 for ; Mon, 16 Dec 2019 18:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576520220; bh=zJCOqmJyuSeJGxNNSUsgQII3CyhLR6EHjhTErZkdbLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=fbEfzql+H+7lcsAcJXBhHCVa08X8yQgbdnbUunh4umk3QpFujEzWxH/bqejNLgS0j 4rglJlweIEOph3zSPEbXi5wzRqEI3bNjn9oMMUfKowbMEW8WJ2EHpCDA6RgC3rbNsB Fthg55Ye2kOm0Hmdy29t60NUZHjnTHPMz2u9gehs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731616AbfLPSQ7 (ORCPT ); Mon, 16 Dec 2019 13:16:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:40232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731429AbfLPSQ6 (ORCPT ); Mon, 16 Dec 2019 13:16:58 -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 9C275206EC; Mon, 16 Dec 2019 18:16:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576520218; bh=zJCOqmJyuSeJGxNNSUsgQII3CyhLR6EHjhTErZkdbLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qBQcbfuvBVamgj+S6Pf9kHQ5Qt9lVz9+wQPyoAntTy/FOoZkK81FnM2DM8cNFPR0l OERc/8wEn/OX8wjaw9RIGndwRvEPDeqybZJh9bbYIbTKpcbFgzXnPYMxx4/Xjb3bBh 9azV8bo4OxKAbdkJaA8XerFekzXIm4W+Ga3yTdx4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , linux-usb@vger.kernel.org, =?utf-8?q?Heikki_Krogerus=C2=A0?= Subject: [PATCH 5.4 064/177] usb: typec: fix use after free in typec_register_port() Date: Mon, 16 Dec 2019 18:48:40 +0100 Message-Id: <20191216174832.699676929@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174811.158424118@linuxfoundation.org> References: <20191216174811.158424118@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Wen Yang commit 5c388abefda0d92355714010c0199055c57ab6c7 upstream. We can't use "port->sw" and/or "port->mux" after it has been freed. Fixes: 23481121c81d ("usb: typec: class: Don't use port parent for getting mux handles") Signed-off-by: Wen Yang Cc: stable Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Acked-by: Heikki Krogerus  Link: https://lore.kernel.org/r/20191126140452.14048-1-wenyang@linux.alibaba.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/class.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1592,14 +1592,16 @@ struct typec_port *typec_register_port(s port->sw = typec_switch_get(&port->dev); if (IS_ERR(port->sw)) { + ret = PTR_ERR(port->sw); put_device(&port->dev); - return ERR_CAST(port->sw); + return ERR_PTR(ret); } port->mux = typec_mux_get(&port->dev, NULL); if (IS_ERR(port->mux)) { + ret = PTR_ERR(port->mux); put_device(&port->dev); - return ERR_CAST(port->mux); + return ERR_PTR(ret); } ret = device_add(&port->dev);