Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 7b5ab04f035f ("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

authored by

Dan Carpenter and committed by
Thomas Gleixner
c7418164 ac3fd01e

+3 -1
+3 -1
kernel/time/timekeeping.c
··· 3073 3073 char id[2] = { [0] = '0' + i, }; 3074 3074 struct kobject *clk = kobject_create_and_add(id, auxo); 3075 3075 3076 - if (!clk) 3076 + if (!clk) { 3077 + ret = -ENOMEM; 3077 3078 goto err_clean; 3079 + } 3078 3080 3079 3081 ret = sysfs_create_group(clk, &aux_clock_enable_attr_group); 3080 3082 if (ret)