From patchwork Sun Jun 6 20:09:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12302269 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 36D55C4743E for ; Sun, 6 Jun 2021 20:11:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03CE0613AD for ; Sun, 6 Jun 2021 20:11:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229944AbhFFUMx (ORCPT ); Sun, 6 Jun 2021 16:12:53 -0400 Received: from fgw23-7.mail.saunalahti.fi ([62.142.5.84]:57733 "EHLO fgw23-7.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbhFFUMx (ORCPT ); Sun, 6 Jun 2021 16:12:53 -0400 Received: from localhost (88-115-248-186.elisa-laajakaista.fi [88.115.248.186]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id 5087b670-c703-11eb-8ccd-005056bdfda7; Sun, 06 Jun 2021 23:11:01 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Heikki Krogerus , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 1/3] usb: typec: intel_pmc_mux: Put fwnode in error case during ->probe() Date: Sun, 6 Jun 2021 23:09:09 +0300 Message-Id: <20210606200911.32076-1-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org device_get_next_child_node() bumps a reference counting of a returned variable. We have to balance it whenever we return to the caller. Fixes: 6701adfa9693 ("usb: typec: driver for Intel PMC mux control") Cc: Heikki Krogerus Signed-off-by: Andy Shevchenko --- drivers/usb/typec/mux/intel_pmc_mux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index 46a25b8db72e..134325444e6a 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -645,6 +645,7 @@ static int pmc_usb_probe(struct platform_device *pdev) return 0; err_remove_ports: + fwnode_handle_put(fwnode); for (i = 0; i < pmc->num_ports; i++) { typec_switch_unregister(pmc->port[i].typec_sw); typec_mux_unregister(pmc->port[i].typec_mux); From patchwork Sun Jun 6 20:09:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12302273 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 2A15FC4743F for ; Sun, 6 Jun 2021 20:12:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 097EE613AF for ; Sun, 6 Jun 2021 20:12:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230156AbhFFUNN (ORCPT ); Sun, 6 Jun 2021 16:13:13 -0400 Received: from fgw21-7.mail.saunalahti.fi ([62.142.5.82]:28512 "EHLO fgw21-7.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbhFFUNM (ORCPT ); Sun, 6 Jun 2021 16:13:12 -0400 Received: from localhost (88-115-248-186.elisa-laajakaista.fi [88.115.248.186]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id 53c9277b-c703-11eb-9eb8-005056bdd08f; Sun, 06 Jun 2021 23:11:07 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Heikki Krogerus , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 2/3] usb: typec: intel_pmc_mux: Add missed error check for devm_ioremap_resource() Date: Sun, 6 Jun 2021 23:09:10 +0300 Message-Id: <20210606200911.32076-2-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210606200911.32076-1-andy.shevchenko@gmail.com> References: <20210606200911.32076-1-andy.shevchenko@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org devm_ioremap_resource() can return an error, add missed check for it. Fixes: 43d596e32276 ("usb: typec: intel_pmc_mux: Check the port status before connect") Cc: Heikki Krogerus Signed-off-by: Andy Shevchenko Reviewed-by: Heikki Krogerus --- drivers/usb/typec/mux/intel_pmc_mux.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index 134325444e6a..de40276cc18b 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -586,6 +586,11 @@ static int pmc_usb_probe_iom(struct pmc_usb *pmc) return -ENOMEM; } + if (IS_ERR(pmc->iom_base)) { + put_device(&adev->dev); + return PTR_ERR(pmc->iom_base); + } + pmc->iom_adev = adev; return 0; From patchwork Sun Jun 6 20:09:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12302271 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=-13.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 49B29C4743E for ; Sun, 6 Jun 2021 20:11:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26DB6613AD for ; Sun, 6 Jun 2021 20:11:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230105AbhFFUNC (ORCPT ); Sun, 6 Jun 2021 16:13:02 -0400 Received: from fgw20-7.mail.saunalahti.fi ([62.142.5.81]:27351 "EHLO fgw20-7.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbhFFUNB (ORCPT ); Sun, 6 Jun 2021 16:13:01 -0400 Received: from localhost (88-115-248-186.elisa-laajakaista.fi [88.115.248.186]) by fgw20.mail.saunalahti.fi (Halon) with ESMTP id 558f3bca-c703-11eb-ba24-005056bd6ce9; Sun, 06 Jun 2021 23:11:10 +0300 (EEST) From: Andy Shevchenko To: Greg Kroah-Hartman , Heikki Krogerus , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 3/3] usb: typec: intel_pmc_mux: Put ACPI device using acpi_dev_put() Date: Sun, 6 Jun 2021 23:09:11 +0300 Message-Id: <20210606200911.32076-3-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210606200911.32076-1-andy.shevchenko@gmail.com> References: <20210606200911.32076-1-andy.shevchenko@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org For ACPI devices we have a symmetric API to put them, so use it in the driver. Signed-off-by: Andy Shevchenko Reviewed-by: Heikki Krogerus --- drivers/usb/typec/mux/intel_pmc_mux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index de40276cc18b..2d0a863956c7 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -582,12 +582,12 @@ static int pmc_usb_probe_iom(struct pmc_usb *pmc) acpi_dev_free_resource_list(&resource_list); if (!pmc->iom_base) { - put_device(&adev->dev); + acpi_dev_put(adev); return -ENOMEM; } if (IS_ERR(pmc->iom_base)) { - put_device(&adev->dev); + acpi_dev_put(adev); return PTR_ERR(pmc->iom_base); } @@ -657,7 +657,7 @@ static int pmc_usb_probe(struct platform_device *pdev) usb_role_switch_unregister(pmc->port[i].usb_sw); } - put_device(&pmc->iom_adev->dev); + acpi_dev_put(pmc->iom_adev); return ret; } @@ -673,7 +673,7 @@ static int pmc_usb_remove(struct platform_device *pdev) usb_role_switch_unregister(pmc->port[i].usb_sw); } - put_device(&pmc->iom_adev->dev); + acpi_dev_put(pmc->iom_adev); return 0; }