Re: [PATCH] pci: pcie-rcar: fix a potential NULL pointer dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Kangjie,

On Thu, Mar 14, 2019 at 6:56 AM Kangjie Lu <kjlu@xxxxxxx> 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@xxxxxxx>

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@xxxxxxxxx>

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

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux