* [PATCH] rtc: sysfs: fix NULL check in rtc_add_groups()
@ 2018-08-27 9:22 Dan Carpenter
2018-08-27 21:05 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2018-08-27 9:22 UTC (permalink / raw)
To: Alessandro Zummo, Denis Osterland
Cc: Alexandre Belloni, linux-rtc, kernel-janitors
devm_kcalloc() returns NULL, it never returns error pointers. In the
current code we would return PTR_ERR(NULL) which is success, instead of
returning the -ENOMEM error code.
Fixes: a0a1a1ba3032 ("rtc: sysfs: facilitate attribute add to rtc device")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c
index f1ff30ade534..9746c32eee2e 100644
--- a/drivers/rtc/rtc-sysfs.c
+++ b/drivers/rtc/rtc-sysfs.c
@@ -338,8 +338,8 @@ int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
new_cnt = old_cnt + add_cnt + 1;
groups = devm_kcalloc(&rtc->dev, new_cnt, sizeof(*groups), GFP_KERNEL);
- if (IS_ERR_OR_NULL(groups))
- return PTR_ERR(groups);
+ if (!groups)
+ return -ENOMEM;
memcpy(groups, rtc->dev.groups, old_cnt * sizeof(*groups));
memcpy(groups + old_cnt, grps, add_cnt * sizeof(*groups));
groups[old_cnt + add_cnt] = NULL;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rtc: sysfs: fix NULL check in rtc_add_groups()
2018-08-27 9:22 [PATCH] rtc: sysfs: fix NULL check in rtc_add_groups() Dan Carpenter
@ 2018-08-27 21:05 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2018-08-27 21:05 UTC (permalink / raw)
To: Dan Carpenter
Cc: Alessandro Zummo, Denis Osterland, linux-rtc, kernel-janitors
On 27/08/2018 12:22:34+0300, Dan Carpenter wrote:
> devm_kcalloc() returns NULL, it never returns error pointers. In the
> current code we would return PTR_ERR(NULL) which is success, instead of
> returning the -ENOMEM error code.
>
> Fixes: a0a1a1ba3032 ("rtc: sysfs: facilitate attribute add to rtc device")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
Applied, thanks.
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-28 0:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-27 9:22 [PATCH] rtc: sysfs: fix NULL check in rtc_add_groups() Dan Carpenter
2018-08-27 21:05 ` Alexandre Belloni
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).