Skip to content

Commit c741816

Browse files
Dan CarpenterKAGA-KOKO
authored andcommitted
timekeeping: Fix error code in tk_aux_sysfs_init()
If kobject_create_and_add() fails on the first iteration, then the error code is set to -ENOMEM which is correct. But if it fails in subsequent iterations then "ret" is zero, which means success, but it should be -ENOMEM. Set the error code to -ENOMEM correctly. Fixes: 7b5ab04 ("timekeeping: Fix resource leak in tk_aux_sysfs_init() error paths") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Malaya Kumar Rout <mrout@redhat.com> Link: https://patch.msgid.link/aSW1R8q5zoY_DgQE@stanley.mountain
1 parent ac3fd01 commit c741816

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

kernel/time/timekeeping.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3073,8 +3073,10 @@ static int __init tk_aux_sysfs_init(void)
30733073
char id[2] = { [0] = '0' + i, };
30743074
struct kobject *clk = kobject_create_and_add(id, auxo);
30753075

3076-
if (!clk)
3076+
if (!clk) {
3077+
ret = -ENOMEM;
30773078
goto err_clean;
3079+
}
30783080

30793081
ret = sysfs_create_group(clk, &aux_clock_enable_attr_group);
30803082
if (ret)

0 commit comments

Comments
 (0)