lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAKY2RybJ+kyj=5E1pnu2RUEW3T7rXLrqyedR5LkfX=bUOv=_8A@mail.gmail.com>
Date: Wed, 24 Sep 2025 11:37:36 +0530
From: Rahul Kumar <rk0006818@...il.com>
To: Jani Nikula <jani.nikula@...ux.intel.com>
Cc: lanzano.alex@...il.com, maarten.lankhorst@...ux.intel.com, 
	mripard@...nel.org, tzimmermann@...e.de, airlied@...il.com, simona@...ll.ch, 
	dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org, 
	linux-kernel-mentees@...ts.linuxfoundation.org, skhan@...uxfoundation.org
Subject: Re: [PATCH] drm/tiny: Use kmalloc_array() instead of kmalloc()

On Tue, Sep 23, 2025 at 7:21 PM Jani Nikula <jani.nikula@...ux.intel.com> wrote:
>
> On Tue, 23 Sep 2025, Rahul Kumar <rk0006818@...il.com> wrote:
> > Documentation/process/deprecated.rst recommends against the use of
> > kmalloc with dynamic size calculations due to the risk of overflow and
> > smaller allocation being made than the caller was expecting.
> >
> > Replace kmalloc() with kmalloc_array() in drivers/gpu/drm/tiny/repaper.c
> > to make the intended allocation size clearer and avoid potential overflow
> > issues.
> >
> > Signed-off-by: Rahul Kumar <rk0006818@...il.com>
> > ---
> >  drivers/gpu/drm/tiny/repaper.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c
> > index 5c3b51eb0a97..4d439a2d973a 100644
> > --- a/drivers/gpu/drm/tiny/repaper.c
> > +++ b/drivers/gpu/drm/tiny/repaper.c
> > @@ -535,7 +535,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb,
> >       DRM_DEBUG("Flushing [FB:%d] st=%ums\n", fb->base.id,
> >                 epd->factored_stage_time);
> >
> > -     buf = kmalloc(fb->width * fb->height / 8, GFP_KERNEL);
> > +     buf = kmalloc_array(fb->width, fb->height / 8, GFP_KERNEL);
>
> That's just not the same thing, though.
>

Thanks Jani, you are right. My change made the allocation size
different from the original (width * height / 8). The current code is
fine, so I will not change it.

Thanks,
Rahul


> BR,
> Jani.
>
> >       if (!buf) {
> >               ret = -ENOMEM;
> >               goto out_exit;
>
> --
> Jani Nikula, Intel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ