kobject: Use return value of strreplace()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 5 Jun 2023 17:05:53 +0000 (20:05 +0300)
committerKees Cook <keescook@chromium.org>
Mon, 5 Jun 2023 22:31:12 +0000 (15:31 -0700)
Since strreplace() returns the pointer to the string itself,
we may use it directly in the code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230605170553.7835-4-andriy.shevchenko@linux.intel.com
lib/kobject.c

index f79a434..16d530f 100644 (file)
@@ -281,8 +281,7 @@ int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
                kfree_const(s);
                if (!t)
                        return -ENOMEM;
-               strreplace(t, '/', '!');
-               s = t;
+               s = strreplace(t, '/', '!');
        }
        kfree_const(kobj->name);
        kobj->name = s;