[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210211071153.GJ20820@kadam>
Date: Thu, 11 Feb 2021 10:11:53 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Drew Fustini <drew@...gleboard.org>
Cc: Linus Walleij <linus.walleij@...aro.org>,
linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
Tony Lindgren <tony@...mide.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Pantelis Antoniou <pantelis.antoniou@...sulko.com>,
Jason Kridner <jkridner@...gleboard.org>,
Robert Nelson <robertcnelson@...gleboard.org>,
Joe Perches <joe@...ches.com>
Subject: Re: [PATCH v4 2/2] pinctrl: pinmux: Add pinmux-select debugfs file
On Wed, Feb 10, 2021 at 02:28:54PM -0800, Drew Fustini wrote:
> + ret = strncpy_from_user(buf, user_buf, PINMUX_MAX_NAME * 2);
> + if (ret < 0) {
> + dev_err(pctldev->dev, "failed to copy buffer from userspace");
> + goto free_gname;
> + }
> + buf[len-1] = '\0';
> +
> + ret = sscanf(buf, "%s %s", fname, gname);
> + if (ret != 2) {
> + dev_err(pctldev->dev, "expected format: <function-name> <group-name>");
> + goto free_gname;
We need a "ret = -EINVAL;" before the goto. sscanf doesn't return error
codes. Normally we would write it like so:
if (sscanf(buf, "%s %s", fname, gname) != 2) {
dev_err(pctldev->dev, "expected format: <function-name> <group-name>");
ret = -EINVAL;
goto free_gname;
}
I'm going to write a Smatch check for this today.
> + }
> +
> + fsel = pinmux_func_name_to_selector(pctldev, fname);
> + if (fsel < 0) {
> + dev_err(pctldev->dev, "invalid function %s in map table\n", fname);
> + ret = -EINVAL;
ret = fsel;
> + goto free_gname;
> + }
> +
regards,
dan carpenter
Powered by blists - more mailing lists