]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
regmap: debugfs: Fix a erroneous check after snprintf()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 4 Sep 2023 20:04:06 +0000 (22:04 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 11 Sep 2023 00:30:07 +0000 (01:30 +0100)
This error handling looks really strange.
Check if the string has been truncated instead.

Fixes: f0c2319f9f19 ("regmap: Expose the driver name in debugfs")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/8595de2462c490561f70020a6d11f4d6b652b468.1693857825.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap-debugfs.c

index f36027591e1a8db986c54a2f04f1a645d5f77b76..bdd80b73c3e6c17b4dc6955a4349fee34f0adfdb 100644 (file)
@@ -48,7 +48,7 @@ static ssize_t regmap_name_read_file(struct file *file,
                name = map->dev->driver->name;
 
        ret = snprintf(buf, PAGE_SIZE, "%s\n", name);
-       if (ret < 0) {
+       if (ret >= PAGE_SIZE) {
                kfree(buf);
                return ret;
        }