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

Andy Shevchenko andy.shevchenko at gmail.com
Wed Jun 27 21:42:34 UTC 2018


On Wed, Jun 27, 2018 at 11:02 PM, Alexey Dobriyan <adobriyan at gmail.com> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the Linux-security-module-archive mailing list