linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: macb: Fix passing zero to 'PTR_ERR'
@ 2020-11-12 14:49 YueHaibing
  2020-11-14 20:36 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2020-11-12 14:49 UTC (permalink / raw)
  To: nicolas.ferre, claudiu.beznea, davem, kuba, harini.katakam
  Cc: netdev, linux-kernel, YueHaibing

Check PTR_ERR with IS_ERR to fix this.

Fixes: cd5afa91f078 ("net: macb: Add null check for PCLK and HCLK")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 51f866288582..7b1d195787dc 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3711,19 +3711,13 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
 	}
 
 	if (IS_ERR_OR_NULL(*pclk)) {
-		err = PTR_ERR(*pclk);
-		if (!err)
-			err = -ENODEV;
-
+		err = IS_ERR(*pclk) ? PTR_ERR(*pclk) : -ENODEV;
 		dev_err(&pdev->dev, "failed to get macb_clk (%d)\n", err);
 		return err;
 	}
 
 	if (IS_ERR_OR_NULL(*hclk)) {
-		err = PTR_ERR(*hclk);
-		if (!err)
-			err = -ENODEV;
-
+		err = IS_ERR(*hclk) ? PTR_ERR(*hclk) : -ENODEV;
 		dev_err(&pdev->dev, "failed to get hclk (%d)\n", err);
 		return err;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: macb: Fix passing zero to 'PTR_ERR'
  2020-11-12 14:49 [PATCH] net: macb: Fix passing zero to 'PTR_ERR' YueHaibing
@ 2020-11-14 20:36 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2020-11-14 20:36 UTC (permalink / raw)
  To: YueHaibing
  Cc: nicolas.ferre, claudiu.beznea, davem, harini.katakam, netdev,
	linux-kernel

On Thu, 12 Nov 2020 22:49:36 +0800 YueHaibing wrote:
> Check PTR_ERR with IS_ERR to fix this.
> 
> Fixes: cd5afa91f078 ("net: macb: Add null check for PCLK and HCLK")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Looks like a cleanup PTR_ERR() should return 0 for NULL AFAICS.

Applied to net-next, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-14 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 14:49 [PATCH] net: macb: Fix passing zero to 'PTR_ERR' YueHaibing
2020-11-14 20:36 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).