Re: [PATCH] proc: save 2 atomic ops on write to "/proc/*/attr/*"

From: Andy Shevchenko
Date: Wed Jun 27 2018 - 17:42:40 EST


On Wed, Jun 27, 2018 at 11:02 PM, Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:
> Code checks if write is done by current to its own attributes.
> For that get/put pair is unnecessary as it can be done under RCU.

> /* No partial writes. */
> - length = -EINVAL;
> if (*ppos != 0)
> - goto out;
> + return -EINVAL;
>
> page = memdup_user(buf, count);
> if (IS_ERR(page)) {

> - length = PTR_ERR(page);
> + rv = PTR_ERR(page);
> goto out;

You alredy have more than one exit location, why not to convert this
one as well and get rid of out label completely?

> }

> out_free:
> kfree(page);
> out:

> + return rv;
> }

--
With Best Regards,
Andy Shevchenko