mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 07:38:10 +00:00
rtc: sysfs: fix NULL check in rtc_add_groups()
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: a0a1a1ba30
("rtc: sysfs: facilitate attribute add to rtc device")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
725e0e15f8
commit
777d8ae56d
1 changed files with 2 additions and 2 deletions
|
@ -338,8 +338,8 @@ int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps)
|
||||||
|
|
||||||
new_cnt = old_cnt + add_cnt + 1;
|
new_cnt = old_cnt + add_cnt + 1;
|
||||||
groups = devm_kcalloc(&rtc->dev, new_cnt, sizeof(*groups), GFP_KERNEL);
|
groups = devm_kcalloc(&rtc->dev, new_cnt, sizeof(*groups), GFP_KERNEL);
|
||||||
if (IS_ERR_OR_NULL(groups))
|
if (!groups)
|
||||||
return PTR_ERR(groups);
|
return -ENOMEM;
|
||||||
memcpy(groups, rtc->dev.groups, old_cnt * sizeof(*groups));
|
memcpy(groups, rtc->dev.groups, old_cnt * sizeof(*groups));
|
||||||
memcpy(groups + old_cnt, grps, add_cnt * sizeof(*groups));
|
memcpy(groups + old_cnt, grps, add_cnt * sizeof(*groups));
|
||||||
groups[old_cnt + add_cnt] = NULL;
|
groups[old_cnt + add_cnt] = NULL;
|
||||||
|
|
Loading…
Reference in a new issue