lkml.org 
[lkml]   [2019]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] pci: pcie-rcar: fix a potential NULL pointer dereference
Hi Kangjie,

On Thu, Mar 14, 2019 at 6:56 AM Kangjie Lu <kjlu@umn.edu> wrote:
> In case __get_free_pages fails and returns NULL, the fix returns
> -ENOMEM and releases resources to avoid NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

Thanks for your patch!

> --- a/drivers/pci/controller/pcie-rcar.c
> +++ b/drivers/pci/controller/pcie-rcar.c
> @@ -929,6 +929,12 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
>
> /* setup MSI data target */
> msi->pages = __get_free_pages(GFP_KERNEL, 0);
> + if (!msi->pages) {
> + dev_err(dev, "failed to get free pages\n");

Please drop the dev_err().
The memory allocation core will already have printed a warning, cfr.
warn_alloc() in mm/page_alloc.c.

With that fixed:
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> + err = -ENOMEM;
> + goto err;
> + }
> +

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

\
 
 \ /
  Last update: 2019-03-14 08:30    [W:0.071 / U:0.584 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site