Commit c7418164 authored by Dan Carpenter's avatar Dan Carpenter Committed by Thomas Gleixner
Browse files

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: 7b5ab04f ("timekeeping: Fix resource leak in tk_aux_sysfs_init() error paths")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarMalaya Kumar Rout <mrout@redhat.com>
Link: https://patch.msgid.link/aSW1R8q5zoY_DgQE@stanley.mountain
parent ac3fd01e
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -3073,8 +3073,10 @@ static int __init tk_aux_sysfs_init(void)
		char id[2] = { [0] = '0' + i, };
		struct kobject *clk = kobject_create_and_add(id, auxo);

		if (!clk)
		if (!clk) {
			ret = -ENOMEM;
			goto err_clean;
		}

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