From: Cong Ding Date: Tue, 15 Jan 2013 19:46:50 +0000 (+0100) Subject: staging: omapdrm/omap_gem_dmabuf.c: fix memory leakage X-Git-Url: https://rtime.felk.cvut.cz/gitweb/linux-imx.git/commitdiff_plain/cce17b457b3b346e5777ec770feb324663ea2b9b staging: omapdrm/omap_gem_dmabuf.c: fix memory leakage There is a memory leakage in variable sg if it goes to error. Signed-off-by: Cong Ding Signed-off-by: Rob Clark Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/omapdrm/omap_gem_dmabuf.c b/drivers/staging/omapdrm/omap_gem_dmabuf.c index eabb8b57f6c3..27780b8bf155 100644 --- a/drivers/staging/omapdrm/omap_gem_dmabuf.c +++ b/drivers/staging/omapdrm/omap_gem_dmabuf.c @@ -53,10 +53,10 @@ static struct sg_table *omap_gem_map_dma_buf( /* this should be after _get_paddr() to ensure we have pages attached */ omap_gem_dma_sync(obj, dir); -out: - if (ret) - return ERR_PTR(ret); return sg; +out: + kfree(sg); + return ERR_PTR(ret); } static void omap_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,