From patchwork Wed Mar 9 17:00:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12775336 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BEC2AC433FE for ; Wed, 9 Mar 2022 17:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=N4FtvOquvu4+XuYfMrfy1YWafra6O16amDQjuJ72F8M=; b=A6j9tQ0DTmkxaC RdC/Cyqt0dZz+M/AosXZzjNI+WfS3IKz9bFX8JIt0W5VmNjacanFOqHq93KoSjk5Fmh7AXwGEWSvI KX8LCF+GFC2ycb2JoSYQClnvy1NqTJmcxocsBkpJjGyxiImvCNQyj/p5dpkxNFgFujqfhDNQ3eSIq dKdWl0QaYA3m5LGYc4FsKE7RY0fJrz0Ei3sG42ieTjRkCLDjY3gvytLQo367IJVPnpM5mHkr6n5IF wYZ93r9y0+/73+W62lYXlphGNnrNAKaqCVXFeaGSeY+f03adMpEg9CuPnQagzLGUazSjburn8dpqX dXvrD5ebZ+OTjBxujTpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRzm0-009h3G-4U; Wed, 09 Mar 2022 17:06:52 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRzft-009eEt-MJ for linux-arm-kernel@lists.infradead.org; Wed, 09 Mar 2022 17:00:35 +0000 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 1C39B3F79D for ; Wed, 9 Mar 2022 17:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1646845232; bh=1C2abaYPYBkDuzkzZwjwXPHr1LgPUoTyCzwwpANsRGs=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=jYFYE8HjbQ361Lz6QyM6p8qfSJMRJKH6Cbq7Q8/dKabL9SFmSZNjD/oKCs3jHn3Es QS4UtCRXLuAImY8I9xOaHwzGps/ngaDCWTykYBh6BJNPPC8LvEj8X906GOJG6Z6zCj YFdhFuN4R3IIb0alGG28AqgesAo7flwbNiGDOdG/WHO/kpAjjWULpqE99v6E+ztI9Y WWaOTQ2CPqzQp5NBgp/R6gECA54TYf2wiJ1AMUC35XOWVCXGaubUbTkRc/G+yyjP3v sn29csMxfRn+ujubdj1AI7wN/qjzQ1iT6KClViGN0cX8Z0UEmaIpcEaQ/33jhIfXFt +yDI6hrnAqhkA== Received: by mail-ed1-f69.google.com with SMTP id n11-20020aa7c68b000000b0041641550e11so1620956edq.8 for ; Wed, 09 Mar 2022 09:00:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=1C2abaYPYBkDuzkzZwjwXPHr1LgPUoTyCzwwpANsRGs=; b=P/bHYcmOvSpiPmW3CDon5LbPbapYVfq+96mTybKhkxw4F12ib9DXBTeVWuacKTy4+7 4xeeRmsGr+yh61B/dp+FmyG6gw1/r1yJT81X86J+JJldIgkWXa+7/WjGpaOx8YQycQcP I8Mvj8ANUUFimjoIQ+1l3svsshCks1O7m3chTU/MrRieod0/nPMrCY6QyRQTbux8EoQo 295q/hTwb0q29TAEk45cSdKvO0UDhViyhRVHPX0Rcp6BKaMq9HP1ZnR2EjvrKBXq6fDu +PyXHiXc76QLQ1vKzhVHK92repvfb8SgQ92F9PF/6T9I8p/NZvlkNFssXC0hbtbYVfGK bvLQ== X-Gm-Message-State: AOAM530LbZF4D/0jusR1PJrIaiM6RdiklURYIC0ZLNWgzTthOhjjhd8J SKWljCyzzvCKTPeeXCIF+EX0XxFj5NHPOBovRxyIWeuo/fZcTwhE233js36bM5AomHBX/n9jvyf +rv2eSHRbZowNrwXAFjFCYvksSyjA25xKBjhdPMDUuZ7qv2nFCtFy X-Received: by 2002:a17:906:6a26:b0:6da:873c:b9a2 with SMTP id qw38-20020a1709066a2600b006da873cb9a2mr647421ejc.727.1646845231649; Wed, 09 Mar 2022 09:00:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrw1wchW3O6ryE+IVn5BJTWoAbUv5bAvi3pD7v2cxZRa7DtGFD01MOWRsewZfconSJ8erZ5A== X-Received: by 2002:a17:906:6a26:b0:6da:873c:b9a2 with SMTP id qw38-20020a1709066a2600b006da873cb9a2mr647400ejc.727.1646845231437; Wed, 09 Mar 2022 09:00:31 -0800 (PST) Received: from localhost.localdomain (xdsl-188-155-174-239.adslplus.ch. [188.155.174.239]) by smtp.gmail.com with ESMTPSA id h22-20020a1709062dd600b006dac66b8076sm944767eji.95.2022.03.09.09.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 09:00:30 -0800 (PST) From: Krzysztof Kozlowski To: Kishon Vijay Abraham I , Vinod Koul , Krzysztof Kozlowski , Alim Akhtar , Miaoqian Lin , linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] phy: samsung: exynos5250-sata: fix missing device put in probe error paths Date: Wed, 9 Mar 2022 18:00:28 +0100 Message-Id: <20220309170028.51913-1-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220309_090033_917188_940E821E X-CRM114-Status: GOOD ( 14.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The actions of of_find_i2c_device_by_node() in probe function should be reversed in error paths by putting the reference to obtained device. Fixes: bcff4cba41bc ("PHY: Exynos: Add Exynos5250 SATA PHY driver") Signed-off-by: Krzysztof Kozlowski Reviewed-by: Alim Akhtar --- Rebased on top of (although it is independent, no conflicts): https://lore.kernel.org/linux-samsung-soc/20220309124856.32632-1-linmq006@gmail.com/T/#u --- drivers/phy/samsung/phy-exynos5250-sata.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/phy/samsung/phy-exynos5250-sata.c b/drivers/phy/samsung/phy-exynos5250-sata.c index 6c305a3fe187..595adba5fb8f 100644 --- a/drivers/phy/samsung/phy-exynos5250-sata.c +++ b/drivers/phy/samsung/phy-exynos5250-sata.c @@ -196,20 +196,21 @@ static int exynos_sata_phy_probe(struct platform_device *pdev) sata_phy->phyclk = devm_clk_get(dev, "sata_phyctrl"); if (IS_ERR(sata_phy->phyclk)) { dev_err(dev, "failed to get clk for PHY\n"); - return PTR_ERR(sata_phy->phyclk); + ret = PTR_ERR(sata_phy->phyclk); + goto put_dev; } ret = clk_prepare_enable(sata_phy->phyclk); if (ret < 0) { dev_err(dev, "failed to enable source clk\n"); - return ret; + goto put_dev; } sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops); if (IS_ERR(sata_phy->phy)) { - clk_disable_unprepare(sata_phy->phyclk); dev_err(dev, "failed to create PHY\n"); - return PTR_ERR(sata_phy->phy); + ret = PTR_ERR(sata_phy->phy); + goto clk_disable; } phy_set_drvdata(sata_phy->phy, sata_phy); @@ -217,11 +218,18 @@ static int exynos_sata_phy_probe(struct platform_device *pdev) phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); if (IS_ERR(phy_provider)) { - clk_disable_unprepare(sata_phy->phyclk); - return PTR_ERR(phy_provider); + ret = PTR_ERR(phy_provider); + goto clk_disable; } return 0; + +clk_disable: + clk_disable_unprepare(sata_phy->phyclk); +put_dev: + put_device(&sata_phy->client->dev); + + return ret; } static const struct of_device_id exynos_sata_phy_of_match[] = {