Skip to contentSkip to conversation

rtc: gamecube: Fix an IS_ERR() vs NULL check

PATCH Applied Dan Carpenter 3 participants 3 messages Jan 7, 2022 – Jan 16, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: gamecube: Fix an IS_ERR() vs NULL check

The devm_kzalloc() function returns NULL on error, it doesn't return error pointers.

Fixes 86559400b3ef ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U")
---
 drivers/rtc/rtc-gamecube.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-gamecube.c +2 -2
index 98128746171e..f717b36f4738 100644
@@ -319,8 +319,8 @@ static int gamecube_rtc_probe(struct platform_device *pdev)
 	int ret;
 
 	d = devm_kzalloc(dev, sizeof(struct priv), GFP_KERNEL);
-	if (IS_ERR(d))
-		return PTR_ERR(d);
+	if (!d)
+		return -ENOMEM;
 
 	d->iob = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(d->iob))
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Dan Carpenter

The devm_kzalloc() function returns NULL on error, it doesn't return error pointers.

Good catch, thanks!

Quoted 24 lines
Fixes 86559400b3ef ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U")
---
 drivers/rtc/rtc-gamecube.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-gamecube.c +2 -2
index 98128746171e..f717b36f4738 100644
@@ -319,8 +319,8 @@ static int gamecube_rtc_probe(struct platform_device *pdev)
 	int ret;
 
 	d = devm_kzalloc(dev, sizeof(struct priv), GFP_KERNEL);
-	if (IS_ERR(d))
-		return PTR_ERR(d);
+	if (!d)
+		return -ENOMEM;
 
 	d->iob = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(d->iob))
Signature · 1 line
2.20.1
Signature · 1 line
Emmanuel Gil Peyrot
maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

The devm_kzalloc() function returns NULL on error, it doesn't return error pointers.

Applied, thanks!

[1/1] rtc: gamecube: Fix an IS_ERR() vs NULL check

      commit: 900ed72c8a190e8c0b87cb17abc645b8ec713011

Best regards,

Signature · 1 line
Alexandre Belloni <[email protected]>