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: <CAO8GWq=5PEp5ikB_YZ+bUPuKoGWS8jNed7QZECCTmR2qDTMcXg@mail.gmail.com>
Date:	Fri, 17 Aug 2012 12:27:01 -0500
From:	"Clark, Rob" <rob@...com>
To:	emilgoode@...il.com
Cc:	gregkh@...uxfoundation.org, andy.gross@...com,
	daniel.vetter@...ll.ch, devel@...verdev.osuosl.org,
	linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] staging: drm/omap: Add error handling

On Fri, Aug 17, 2012 at 11:53 AM,  <emilgoode@...il.com> wrote:
> From: Emil Goode <emilgoode@...il.com>
>
> This patch adds fail checks for kmalloc and kzalloc calls
> and also adds a error path that frees allocated pages by
> introducing a call to _drm_gem_put_pages.
>
> Signed-off-by: Emil Goode <emilgoode@...il.com>

Looks good, thanks

Signed-off-by: Rob Clark <rob@...com>

> ---
>  drivers/staging/omapdrm/omap_gem.c |   17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/omapdrm/omap_gem.c b/drivers/staging/omapdrm/omap_gem.c
> index 74082aa..c828743 100644
> --- a/drivers/staging/omapdrm/omap_gem.c
> +++ b/drivers/staging/omapdrm/omap_gem.c
> @@ -226,7 +226,8 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
>         struct drm_device *dev = obj->dev;
>         struct omap_gem_object *omap_obj = to_omap_bo(obj);
>         struct page **pages;
> -       int i, npages = obj->size >> PAGE_SHIFT;
> +       int npages = obj->size >> PAGE_SHIFT;
> +       int i, ret;
>         dma_addr_t *addrs;
>
>         WARN_ON(omap_obj->pages);
> @@ -246,18 +247,32 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
>          */
>         if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
>                 addrs = kmalloc(npages * sizeof(addrs), GFP_KERNEL);
> +               if (!addrs) {
> +                       ret = -ENOMEM;
> +                       goto free_pages;
> +               }
> +
>                 for (i = 0; i < npages; i++) {
>                         addrs[i] = dma_map_page(dev->dev, pages[i],
>                                         0, PAGE_SIZE, DMA_BIDIRECTIONAL);
>                 }
>         } else {
>                 addrs = kzalloc(npages * sizeof(addrs), GFP_KERNEL);
> +               if (!addrs) {
> +                       ret = -ENOMEM;
> +                       goto free_pages;
> +               }
>         }
>
>         omap_obj->addrs = addrs;
>         omap_obj->pages = pages;
>
>         return 0;
> +
> +free_pages:
> +       _drm_gem_put_pages(obj, pages, true, false);
> +
> +       return ret;
>  }
>
>  /** release backing pages */
> --
> 1.7.10.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ