From patchwork Mon Nov 14 17:44:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 19941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2275659wru; Mon, 14 Nov 2022 09:46:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf49RvGq/xAj8BLpUk7dDPGe3nNEkrQH5BUz6XWdlTsogep2ZZlB0AeuEot1R6K+nhODRyGk X-Received: by 2002:a05:6402:3902:b0:468:15f1:54b5 with SMTP id fe2-20020a056402390200b0046815f154b5mr2013115edb.8.1668447994647; Mon, 14 Nov 2022 09:46:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668447994; cv=none; d=google.com; s=arc-20160816; b=BLIdCAWGxg6xQrVtjwtkYlmXOYvlP6B0RFdY1qrvWE4TVKTpp7juAUKegY1yXjio/W 3zRMiEUqx1G0zhWmn23lD57jERmFVy6DSaoW1JZJmaDkUxueStlHSxRPXtoM0JgvFntU mu5M9yKy9f6QFnNmjNcppbAlnIY3ICgiVSSaibm5CsVZKVccUkX0+3ecmFUJqfixznEY yx/bppuCssaJG1MootQl8vz8/rknFX3iba5xtI4AdYjyhtRS3Po4xR89Sb7Kv8twXKBh Eeb+AAF7LTNXyQ5gouXL9Qtgu4JHbEWdoEKpM39hV9JfYcy8S40xwZNLt01A/ECRC1bA FTeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=vMxy/5Ep6z8xTyah49JP7LX4W4hXdf9xwgHuikKY72M=; b=ZcC4Easg5BhN6X9yIBsJhtGrZtGUT7v8b/f/hN9Xu3leFFQXtE3unPBs5++xKMIAco 4LteJeIf4FB4R9ooRUaffH8XP0KAFD2jPDBZUGYPeI0WHPlCf2x/hmFKAM95txbyzckr 6RT0LEQ1lR4G/hLXArycFTwGt7W6ev8OhL8sK/kEKNnhP1eyuA71gC1izvYiI9jV7Q7Z MRzK38eozIoa42roYsASD6777d9FrmRYh8HcmguC9JtxbeFiU8Dsq8i6FVo1kk4DQNNa 87ae0YFkZiYD7rkPXy/Qih6TQhU87olJ/TTyOeXvbcRYdJ4HDm97Ta/gY2h3+Ac04ROa IRcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b=gLtoIFAS; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=cJhN3xTu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svenpeter.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o11-20020a170906974b00b0078d4a0c77f9si10457465ejy.458.2022.11.14.09.46.09; Mon, 14 Nov 2022 09:46:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b=gLtoIFAS; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=cJhN3xTu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237438AbiKNRo4 (ORCPT + 99 others); Mon, 14 Nov 2022 12:44:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237395AbiKNRoy (ORCPT ); Mon, 14 Nov 2022 12:44:54 -0500 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2D7125C0; Mon, 14 Nov 2022 09:44:53 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 690E75C00ED; Mon, 14 Nov 2022 12:44:53 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 14 Nov 2022 12:44:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm1; t=1668447893; x=1668534293; bh=vMxy/5Ep6z 8xTyah49JP7LX4W4hXdf9xwgHuikKY72M=; b=gLtoIFASX/fLQRLrI/h9jTax7p O/KAJ5C/fsKgbWyMcl7cxPio9Xs6o1i+kFeireANe2+loloq+rE45tpRhrLJl+8t nseMb0RGXgBToUHBg6vwnLxt3WfEQW47oqT0j8sU8od4WwcXGASUDsPDpPlU9Rpg w7sxkssw52zxtULaVVcgJsply9Mtp5ReJAPPZ7tPopQzd98vEibRNrxX5/kH2P1V rc+XNeL04umtrtkIl5l8eSjbuHHOgX7gRLz7yTyRZ6hIMQKb3U/xtVWgQCiYIoN7 43Rj41gh/zNHGJ1HphUsgX7JWuWHkkUmC1ajBFjsTG21P6ImhBIH2Y/MlYfw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1668447893; x=1668534293; bh=vMxy/5Ep6z8xTyah49JP7LX4W4hXdf9xwgH uikKY72M=; b=cJhN3xTuNzHHKgf96QzXN+EEIlg/JxLrzBGuuJPUk0ZTrmsbIW+ koz/jtenzfIifmLKnL9DxZviRsZhehyMvcNapMykOPONVeuQ71foudGItvXLMpQZ DFK55X5D2+Xbi0MB1GeK55GSmvhM3GAGjoOAVJYmJIvqgv2v7Ft4oRPy39hw4RZb mEjclqv0eOGATCwkoP7VlOjWcIwHdGeGaR7s+q79sAvDgNNHQS88ph0AjkOMJxh7 CXZPHNaUv2cuXMv6zREocLcbR3a/XQ9h2xKe6A6mZqbCUp3JfYLrnzEVSuVMa7qs gG+6JSfHYlHixg4YK3OtDf7oVk0urHLX96Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedvgdejiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcurfgv thgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvghrnh epleduffeiheeuvedtffevtdeuleeljeduudfgtedtvefhfeffvdfghfejhefgleelnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvghnse hsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Feedback-ID: i51094778:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 14 Nov 2022 12:44:52 -0500 (EST) From: Sven Peter To: Heikki Krogerus , Greg Kroah-Hartman Cc: Sven Peter , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] usb: typec: tipd: Cleanup resources if devm_tps6598_psy_register fails Date: Mon, 14 Nov 2022 18:44:46 +0100 Message-Id: <20221114174449.34634-1-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749494524660641912?= X-GMAIL-MSGID: =?utf-8?q?1749494524660641912?= We can't just return if devm_tps6598_psy_register fails since previous resources are not devres managed and have yet to be cleaned up. Fixes: 10eb0b6ac63a ("usb: typec: tps6598x: Export some power supply properties") Signed-off-by: Sven Peter Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 748ff4f6b5f6..ebc786d728e2 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -827,7 +827,7 @@ static int tps6598x_probe(struct i2c_client *client) ret = devm_tps6598_psy_register(tps); if (ret) - return ret; + goto err_role_put; tps->port = typec_register_port(&client->dev, &typec_cap); if (IS_ERR(tps->port)) { From patchwork Mon Nov 14 17:44:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 19942 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2275822wru; Mon, 14 Nov 2022 09:46:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf4k72PyLdDBwl4RfGY6Y/K4tX1OJJMSiIv2OfsurVz5gRHu1gS+rrsLuQhGChAum0h5ciTT X-Received: by 2002:a17:906:5f8d:b0:7ad:917b:61ec with SMTP id a13-20020a1709065f8d00b007ad917b61ecmr11136984eju.513.1668448016319; Mon, 14 Nov 2022 09:46:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668448016; cv=none; d=google.com; s=arc-20160816; b=tSVoRay2qz0l8Q6n4Z0JpO0GKI/IqF5vpfD5WnNeFqrTPdIzXXTsmoU8uWbfIo6tyK OouqflF4VsUUKel2G5L1xrshH175qgavmD49/AYX+I3jd4Ia6VuKQx98eDyhwh8gXfDC fCLV7k6bks/BV54z5I6juqlHLrkOJPDAl37rkImatYuIapzurMsnTHudNYC1p1UPCQpM 86NanPHNAUM+COE7MWHU4nolmapziIJRoikbwIAkCDC8f/edajA+9R1mUR+wdel11sqk zXJw2PPOihPQ2lDgEODYR5ZV/gS054o1zrdVk5spiLDlh8Bpqgkh4wOFsfI2r1esyhMB b+lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=ePEQ+K9udupnlN1ckTjNp1CUO4deTP+rgDBrWOphwU0=; b=cSaGbxgx2icfw34EkqBnefZU9ADsMaizWukdog6Fi0FbMFfC2ZU9Ura8OgIlKm1CNB As6LGGqJuKtHfjpTv3jfErW9KcAvjdxht4iGdxKjaUsRfKOSc68ZXVlWUcWkNzpYRQ3k +jijvi9nr/hSy/T/Y2klku2g+edD6B6IRIvmBamz56bXx/9ulFcfKh+/v8I0XB3l1mIB DfMs8MTxJHfB4JvJjgnjsqcWU3RCiCehS8fd94Kk9ZmnZBJHoFJRrTtWq89Ib89Jlu33 JtAaSoTeAzt+I1Ho7KLJg9ziSuCVvrgTOQSGeiT0coP44z1c+pPcxK5t6ZKK+aHfGBd0 MBsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b=T4UjzoNT; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=oj1FN3pZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svenpeter.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a0564021e9200b00458985e9d19si11360474edf.632.2022.11.14.09.46.32; Mon, 14 Nov 2022 09:46:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b=T4UjzoNT; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=oj1FN3pZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237509AbiKNRo6 (ORCPT + 99 others); Mon, 14 Nov 2022 12:44:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237435AbiKNRo4 (ORCPT ); Mon, 14 Nov 2022 12:44:56 -0500 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49E18190; Mon, 14 Nov 2022 09:44:55 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id B290C5C0184; Mon, 14 Nov 2022 12:44:54 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 14 Nov 2022 12:44:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1668447894; x= 1668534294; bh=ePEQ+K9udupnlN1ckTjNp1CUO4deTP+rgDBrWOphwU0=; b=T 4UjzoNT4HJ5sQ+Qz2kfXVb59W6eDlirUYEkJV5EYo1vm65tYQOgLcNMueBJDjQN+ NMPlHbxsItjZp2NTHkEd7BmquJJ2k6dbQq1l2uyRjC+DCX/iMKvqVYqxa9RDDN7R hr14q1X/jKI/uiHVFdvyUZPYLa2myvno4uLqY3Vkqcw1WfgzMKKRxCwR9Yggkkrr +Yr9F7yfoYzpQGJ9JUapmRo7YhK0wnFAJexlzFDEZ1c0MiIs/Cj6tSH5sx27e6wj ylqkz8ti+U2Fck1HWZGxZFS2MMeWuSifqNaF/kmBY8Ors4y1sJm9zbCynwJOeWL1 yI4L4weXKbPeSW1ai90tg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1668447894; x=1668534294; bh=ePEQ+K9udupnl N1ckTjNp1CUO4deTP+rgDBrWOphwU0=; b=oj1FN3pZslHl+5+KAsxWERCfe9RXP uWYWO9EEvYKe8iDYr547F+K58qWVgROtVUyK/0TuK8nS7tIuwcVxauOfIjkMshmK Xrqx8CCiG8BJuinyTu2S7bAJVAQrATUkiAH2Zb9SNJ2LLJ+OZJeRgOGuEwTjzLGq VN2nIrVZ5TCHGYs/puP+ctDPQyzXWbjImhuV8CI6fBGs98Nxv/260ZRJEJRb3CtL bMeHvtJgu7uiQtpf8l3AO8QL5hbR3g+nq64Dx1BvntGsi3pTmCyQf2sP7FEw49Fj YJMNTX6J6gG+ST7EraY4CSwY68jH4IfhDDbkYGkECZYsx0qFW7aGQ8bCA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedvgdejiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnhepjeeiheehkeegvdejhfevkeejgfdutdefhfethedtieffleekieeuudefleekjeeg necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Feedback-ID: i51094778:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 14 Nov 2022 12:44:53 -0500 (EST) From: Sven Peter To: Heikki Krogerus , Greg Kroah-Hartman Cc: Sven Peter , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] usb: typec: tipd: Fix spurious fwnode_handle_put in error path Date: Mon, 14 Nov 2022 18:44:47 +0100 Message-Id: <20221114174449.34634-2-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20221114174449.34634-1-sven@svenpeter.dev> References: <20221114174449.34634-1-sven@svenpeter.dev> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749494547172511101?= X-GMAIL-MSGID: =?utf-8?q?1749494547172511101?= The err_role_put error path always calls fwnode_handle_put to release the fwnode. This path can be reached after probe itself has already released that fwnode though. Fix that by moving fwnode_handle_put in the happy path to the very end. Fixes: 18a6c866bb19 ("usb: typec: tps6598x: Add USB role switching logic") Signed-off-by: Sven Peter Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index ebc786d728e2..824e573af570 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -834,7 +834,6 @@ static int tps6598x_probe(struct i2c_client *client) ret = PTR_ERR(tps->port); goto err_role_put; } - fwnode_handle_put(fwnode); if (tps->status & TPS_STATUS_PLUG_PRESENT) { ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &tps->pwr_status); @@ -858,6 +857,7 @@ static int tps6598x_probe(struct i2c_client *client) } i2c_set_clientdata(client, tps); + fwnode_handle_put(fwnode); return 0; From patchwork Mon Nov 14 17:44:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 19944 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2278276wru; Mon, 14 Nov 2022 09:53:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6e9Kt/RLkES9LijDxTQMdQj4wxX10suHcgKcny8mYSvapHxESSl9UsEWz/rzxs35MaqaKA X-Received: by 2002:a17:90a:ac0f:b0:214:149b:cedd with SMTP id o15-20020a17090aac0f00b00214149bceddmr12779262pjq.143.1668448405602; Mon, 14 Nov 2022 09:53:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668448405; cv=none; d=google.com; s=arc-20160816; b=sWBI+KjRR2CviYD3k3ZDaXjdNdWXcbnFM90TIqWyftrKisGYWIZ//vnE9+1wiuzE08 YOvq2cr3HQzce6qJiRBNWoZsMPHvq/z45OyMWsl8gQ1Aw1A2Y3ggbhYVUlRlpu+BKZb5 Xtr+TUP8nvCkmwGV0V14/VAOYIETy0GucHBCFQ/3aLXmhIEJyQxnrn7cf5l7Z2/Ky0Hr 5v+JDwbGPIfYg8VkAxaaol43h9Wvi2AEYBErleS92e8IxDAZsCkSXSEsymHOCxdKg3d3 MI5iiEADDTH+OBTeG3tSZN4M4Nx+TRHDKh7N9jutEav1ihQFYST9ABZtajcTVEI9E5wB dSmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=HV91cHyyAtejZdn17gJSrjXPYFuVs8vpuK6kjSyLhQQ=; b=nSSW5PgR7pcW8eUZ5x+GgJWjZc7/yavh9ysZncIyj4uH4t+iyghoN7bad2k4G6G02E gzztLCk+I9fB9x+WJD/pKGNyl2V5iWEqGjyR6pUBjLiGLbymfKt6Bbbe9PeicWX9ANFF Dz5/JfGDUgnI+REoM6iAchHf2HK7SnRn4+Di1rqOIfXrvl+syAq6d6LP85LDJLBjUI9T v0gjy1dUFic9ZJwLDzo/BDTtrLgnyfM01TDXTev/qPU6UK3PGHWSi9lBieN3d4HMiVuM LXWRSEr2TvIQ9NNNDs1aZ1UIP+GrnjDQoYEv8WNh+13ZYlzVLF+kMztzWk6c3zmfoi/L tEzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b="ac6uxn8/"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=B7jphw5L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svenpeter.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a190-20020a6390c7000000b0046b043d221csi9978848pge.55.2022.11.14.09.53.10; Mon, 14 Nov 2022 09:53:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b="ac6uxn8/"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=B7jphw5L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237556AbiKNRpB (ORCPT + 99 others); Mon, 14 Nov 2022 12:45:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237487AbiKNRo5 (ORCPT ); Mon, 14 Nov 2022 12:44:57 -0500 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3465190; Mon, 14 Nov 2022 09:44:56 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id CD2135C00ED; Mon, 14 Nov 2022 12:44:55 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 14 Nov 2022 12:44:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1668447895; x= 1668534295; bh=HV91cHyyAtejZdn17gJSrjXPYFuVs8vpuK6kjSyLhQQ=; b=a c6uxn8/5bNJI7SH1jDcovjMrmWa4H6xnKx7YpwXRxb6GJ33zh1ze4EyDPhalCSVp LY0uB4Sq2hi5rh3pB120Zp1ScfVpt0U+ySroI63Cowt46Y/q/I1X7Q1NIopK+Yk1 5T7i3OzicEDVrcOzksRCn8l1En/6EVVVhEfG78nw/CCByZLrTiMLoiemnM/4B9yp J8Rw9jbh9T/coDAufVY9zwHJkZUjckGJNjXVoOfhn5CJductA2u7PWApPM5BqYfv O7UstElhacVW+i6lt4LJKHqdvXatCtho2lXJm7//ilBXtNk/5uYmtyqF5Zs/upty 2Gav7VclqFyp5RvLemM5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1668447895; x=1668534295; bh=HV91cHyyAtejZ dn17gJSrjXPYFuVs8vpuK6kjSyLhQQ=; b=B7jphw5LCpK5qz0vfAE/bzi+h+9nb LkCAM0CldqkwWDVJfrBM/IUZkV6e07x7nED9YD+51dcYxiKmiJWm/WsuH8qMOtkY 7OAD2RK4jZZ4N1u/gqjgbZUWma3peyMN2ANmDkhfhJBDTj72NN1HLjrtFjabqvRI OGk/R0MRjz7L+V77W9eQsV3LYwLS31VpkFN7EaUgRUqCJhXZFDEM11j03xtPHL1n 4cj6eqRLjh38EZQl7HTqeBa0S5T0R4P8oddVtoCegkxYf/B7XFCdXYm4lR/rjyqz AwYWXSYKGPxF0CYfjtsWTLF00mqtsEAVfP8gpHIc6293W635Y5EHNlDCQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedvgdejiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnhepjeeiheehkeegvdejhfevkeejgfdutdefhfethedtieffleekieeuudefleekjeeg necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Feedback-ID: i51094778:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 14 Nov 2022 12:44:54 -0500 (EST) From: Sven Peter To: Heikki Krogerus , Greg Kroah-Hartman Cc: Sven Peter , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] usb: typec: tipd: Fix typec_unregister_port error paths Date: Mon, 14 Nov 2022 18:44:48 +0100 Message-Id: <20221114174449.34634-3-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20221114174449.34634-1-sven@svenpeter.dev> References: <20221114174449.34634-1-sven@svenpeter.dev> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749494955639885034?= X-GMAIL-MSGID: =?utf-8?q?1749494955639885034?= typec_unregister_port is only called for some error paths after typec_register_port was successful. Ensure it's called in all cases. Fixes: 92440202a880 ("usb: typec: tipd: Only update power status on IRQ") Signed-off-by: Sven Peter Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 824e573af570..c35501a92b4d 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -839,7 +839,7 @@ static int tps6598x_probe(struct i2c_client *client) ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &tps->pwr_status); if (ret < 0) { dev_err(tps->dev, "failed to read power status: %d\n", ret); - goto err_role_put; + goto err_unregister_port; } ret = tps6598x_connect(tps); if (ret) @@ -852,8 +852,7 @@ static int tps6598x_probe(struct i2c_client *client) dev_name(&client->dev), tps); if (ret) { tps6598x_disconnect(tps, 0); - typec_unregister_port(tps->port); - goto err_role_put; + goto err_unregister_port; } i2c_set_clientdata(client, tps); @@ -861,6 +860,8 @@ static int tps6598x_probe(struct i2c_client *client) return 0; +err_unregister_port: + typec_unregister_port(tps->port); err_role_put: usb_role_switch_put(tps->role_sw); err_fwnode_put: From patchwork Mon Nov 14 17:44:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 19943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2276212wru; Mon, 14 Nov 2022 09:47:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf5bJRFUjKzk5rNOE6y2ZPS2p3y7RgecMbT0TGw2MsOYKMt9k9Gpm+SUfQJsDJqgeO50+P3T X-Received: by 2002:a17:906:6d57:b0:78e:108f:295e with SMTP id a23-20020a1709066d5700b0078e108f295emr11210414ejt.544.1668448071935; Mon, 14 Nov 2022 09:47:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668448071; cv=none; d=google.com; s=arc-20160816; b=t5n+wbQogO/UJ/qD7e+VONEboqw4TSiS2QTS9BkMjcMiWaG//dNPdPV5l9t53GCq2k L2OWS+q7wkpNr749bgOIQe/nEACoifC5GwwFFVYyTMquIFaQZTyIzD7yhAXIz11iT+kz Nik6UlzVOFBJqclQ3VzgjOsyAwugTGZCptZ6cK0d5xOGN0dADH5+i8hLtnBHh/F5EPTG NO4cIjSTofeHsXcgkMn0VuYV37SpJSIpwxrPPHgDa+1ns3JiouMYVlR7FPfA5tDjefq0 YxzPGQ6OWJJhNRQFtg5Hn3HNcfgvq7G00vtCNbSPrAhPK9wxx95iJtHJvlb+X836EPRD tTfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=oXWjxeEcaEjt1Kdvuu2aUDoMsSbIcDNUNLWbktQ23lI=; b=yItXcWjgP3lYIlE2wrFrvgCiYBKyaKt7G/WZWBjVX0mCWSmkLVzmOxoRt9NCaCk2Z0 hRzkWnD7Q4CvEJ/xpLyXcP+psPeCVqGzm/ckx5bEX8LALZZqd7zmqyX5zYS2Q76b3jhN 9dOhEVcgt1ULOUWXY/Fmeqq8K9Ljpxvul5Sj5uaMXEKxz8QXbtWDTmhJ9jfq16O6i7bT l2shtm4STvB9mAdcqB73c/9AFfh/DhEQvGxNyX6NvKNzosaUCeBf2U6z0DdOrr0Z07Pw Flt8VGyerv26Oq2iPOV/Ep685Z+TM4B6nwVrovqKg8RvI83CgouhEsn+3P7P3WQu59j8 jvTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b=DeRyyqOg; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=WJh+2gi3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svenpeter.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb34-20020a1709071ca200b007ae6e307f60si10181991ejc.323.2022.11.14.09.47.26; Mon, 14 Nov 2022 09:47:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm1 header.b=DeRyyqOg; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=WJh+2gi3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237606AbiKNRpE (ORCPT + 99 others); Mon, 14 Nov 2022 12:45:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237435AbiKNRpA (ORCPT ); Mon, 14 Nov 2022 12:45:00 -0500 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E0CA190; Mon, 14 Nov 2022 09:44:57 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 03D965C017E; Mon, 14 Nov 2022 12:44:57 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 14 Nov 2022 12:44:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1668447897; x= 1668534297; bh=oXWjxeEcaEjt1Kdvuu2aUDoMsSbIcDNUNLWbktQ23lI=; b=D eRyyqOgj14aphwVKCfuBEM5pyy+IhOggzAAd+Y4mhitJJgkYuS1R/gMRBj6INEpx i0J5hLhJpkpBnHj3i14QXQlw8fddT3sx7P2W9hBDCTFkOInB6oD4u2yp0YuWFBsT Shrd+PVr0Exx9NMyLZ2bIWzYo+eX+p8CoBgR0gRIBHZWOYKxVzIY5aCcZQmwtzbn s0YyQfr+5XprUNDDvCekyNGvkSJ+ObM/FFAyjz0RLo691IchbKAMNhQW9H0b9bte o6uUhPqTkOg8a3FOAS8k8cFhyh03cceVQ1JSJJm+ICBeWHTr2CLGk8YiVvZfih1c YI/pmPf3DYfCD7eyY8R8g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1668447897; x=1668534297; bh=oXWjxeEcaEjt1 Kdvuu2aUDoMsSbIcDNUNLWbktQ23lI=; b=WJh+2gi3v/W/5OQtkcWaqDFKakPg3 mIA6YRDyAwvOGF34iQ2bBncnhfSgVX0Utu9pik+9P/eRVcccPJZVhGdgYROFrnOE mUXyl2JkD9c++MC/dub20aDgBJ419AuS1/Wh9fZojmEslF4sKh81AcFet4jGqy5f BE9xHwUewUYitRq1KboHuj5JnVrDc0NYswOP5ldkx9V+YO13/QMzJOQ4tL8v/Zsy 5nB0kryK6oRfuSEXpGhn8oTXgEXRT5jZP7FORPuJyVKeAJeWIh/XYwIaVwxKcpbU yjLC9iSx/fFzd5vbSlh0jFQfInRZMANNvw3OIXV7ipL/TRnUO3TGFH4DA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedvgdejiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnhepjeeiheehkeegvdejhfevkeejgfdutdefhfethedtieffleekieeuudefleekjeeg necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Feedback-ID: i51094778:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 14 Nov 2022 12:44:55 -0500 (EST) From: Sven Peter To: Heikki Krogerus , Greg Kroah-Hartman Cc: Sven Peter , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] usb: typec: tipd: Move tps6598x_disconnect error path to its own label Date: Mon, 14 Nov 2022 18:44:49 +0100 Message-Id: <20221114174449.34634-4-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20221114174449.34634-1-sven@svenpeter.dev> References: <20221114174449.34634-1-sven@svenpeter.dev> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749494605225124746?= X-GMAIL-MSGID: =?utf-8?q?1749494605225124746?= While the code currently correctly calls tps6598x_disconnect before jumping to the error cleanup label it's inconsistent compared to all the other cleanup actions and prone to introduce bugs if any more resources are added. Signed-off-by: Sven Peter Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index c35501a92b4d..22ff212e05e6 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -850,16 +850,16 @@ static int tps6598x_probe(struct i2c_client *client) irq_handler, IRQF_SHARED | IRQF_ONESHOT, dev_name(&client->dev), tps); - if (ret) { - tps6598x_disconnect(tps, 0); - goto err_unregister_port; - } + if (ret) + goto err_disconnect; i2c_set_clientdata(client, tps); fwnode_handle_put(fwnode); return 0; +err_disconnect: + tps6598x_disconnect(tps, 0); err_unregister_port: typec_unregister_port(tps->port); err_role_put: