From patchwork Thu Nov 21 20:06:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitalii Mordan X-Patchwork-Id: 13882324 X-Patchwork-Delegate: kuba@kernel.org Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1644D1DDA32; Thu, 21 Nov 2024 20:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732219661; cv=none; b=WQpOZz4GVovcdLLPHCprR3jK3W2qPHOpTeJV/qB5m+yNoa7xQ5CTQXafLlWXWN71KY2k7YlaRh/Fh4EZcFAZTwkmR3e1PdHlWm0Y8F/mljjJUx+qKZCv/TcpP2bGa+u5yFXPWGmmsl0OiJTd8f4JPY6qetULZBKTxN9pypYQFYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732219661; c=relaxed/simple; bh=6WLBZ5oLh4c1F5I8IkxBtObd6DgFvu5p7Pko9ptaCTA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ZNmcFuT+RTPyOvXnlWZwgfVMz3lgVVgTijb+DtIZZ8bx7t6RqL9EZzOwPRtD3PGEYaii4kDRdW32yLMRxUKAyZPCO2X21ZRuVcni/9NKu+EKSf6d4lX4J57TJ9j+HNtM/c1dwQyvn2tuwvnAwlVt6R2b/8so9TNMXICbvPYudhk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=FghJhjBV; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="FghJhjBV" Received: from ldvnode.intra.ispras.ru (unknown [10.10.2.153]) by mail.ispras.ru (Postfix) with ESMTPSA id 936E740777A2; Thu, 21 Nov 2024 20:07:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 936E740777A2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1732219653; bh=I42YNcC0Gzw8hiwK4fNvWO8XT241TcT3a5+brZAF+Vk=; h=From:To:Cc:Subject:Date:From; b=FghJhjBVgpooEeDAdGwRoC5rEW6QyAQUxPShsBpd90eX89DaHqAsI6B1ZPRM+DA/d DKtMfeLsvkeXpJgRqM+lTE3ZEKb+AyCfg7qEtbzu2CNXtw4y79IKuu6jjltIUFDKwd fOvEoCH1PqmUv20ltgxLGiwnk1+yAwiVuexvpQS0= From: Vitalii Mordan To: Andrew Lunn Cc: Vitalii Mordan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jacob Keller , Shannon Nelson , Sabrina Dubroca , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Fedor Pchelkin , Alexey Khoroshilov , Vadim Mutilin Subject: [PATCH net] marvell: pxa168_eth: fix call balance of pep->clk handling routines Date: Thu, 21 Nov 2024 23:06:58 +0300 Message-Id: <20241121200658.2203871-1-mordan@ispras.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org If the clock pep->clk was not enabled in pxa168_eth_probe, it should not be disabled in any path. Conversely, if it was enabled in pxa168_eth_probe, it must be disabled in all error paths to ensure proper cleanup. Use the devm_clk_get_enabled helper function to ensure proper call balance for pep->clk. Found by Linux Verification Center (linuxtesting.org) with Klever. Fixes: a49f37eed22b ("net: add Fast Ethernet driver for PXA168.") Signed-off-by: Vitalii Mordan --- drivers/net/ethernet/marvell/pxa168_eth.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c index 1a59c952aa01..45f115e41857 100644 --- a/drivers/net/ethernet/marvell/pxa168_eth.c +++ b/drivers/net/ethernet/marvell/pxa168_eth.c @@ -1394,18 +1394,15 @@ static int pxa168_eth_probe(struct platform_device *pdev) printk(KERN_NOTICE "PXA168 10/100 Ethernet Driver\n"); - clk = devm_clk_get(&pdev->dev, NULL); + clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(clk)) { - dev_err(&pdev->dev, "Fast Ethernet failed to get clock\n"); + dev_err(&pdev->dev, "Fast Ethernet failed to get and enable clock\n"); return -ENODEV; } - clk_prepare_enable(clk); dev = alloc_etherdev(sizeof(struct pxa168_eth_private)); - if (!dev) { - err = -ENOMEM; - goto err_clk; - } + if (!dev) + return -ENOMEM; platform_set_drvdata(pdev, dev); pep = netdev_priv(dev); @@ -1523,8 +1520,6 @@ static int pxa168_eth_probe(struct platform_device *pdev) mdiobus_free(pep->smi_bus); err_netdev: free_netdev(dev); -err_clk: - clk_disable_unprepare(clk); return err; } @@ -1542,7 +1537,6 @@ static void pxa168_eth_remove(struct platform_device *pdev) if (dev->phydev) phy_disconnect(dev->phydev); - clk_disable_unprepare(pep->clk); mdiobus_unregister(pep->smi_bus); mdiobus_free(pep->smi_bus); unregister_netdev(dev);