lkml.org 
[lkml]   [2019]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/5] lib: make bitmap_parselist_user() a wrapper on bitmap_parselist()
On Wed, Apr 03, 2019 at 02:15:22PM +0300, Andy Shevchenko wrote:
> On Wed, Apr 03, 2019 at 07:45:36AM +0300, Yury Norov wrote:
> > Currently we parse user data byte after byte which leads to
> > overcomplification of parsing algorithm. The only user of
> > bitmap_parselist_user() is not performance-critical, and so we
> > can copy user data to kernel buffer and simply call
> > bitmap_parselist(). This rework lets us unify and simplify
> > bitmap_parselist() and bitmap_parselist_user(), which is done
> > in the following patch.
>
> > + buf = kmalloc(ulen + 1, GFP_KERNEL);
> > + if (!buf)
> > + return -ENOMEM;
> > +
> > + buf[ulen] = 0;
> > +
> > + ret = copy_from_user(buf, ubuf, ulen);
> > + if (ret)
> > + goto out;
>
> Why not memdup_user() ?

Even more precisely (for strings) strndup_user().

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2019-04-03 13:18    [W:0.044 / U:1.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site