* [PATCH] dma-buf: Release module reference on creation failure
@ 2016-03-31 8:35 Chris Wilson
2016-03-31 16:14 ` ✗ Fi.CI.BAT: failure for " Patchwork
2016-03-31 16:20 ` [Intel-gfx] [PATCH] " Joonas Lahtinen
0 siblings, 2 replies; 3+ messages in thread
From: Chris Wilson @ 2016-03-31 8:35 UTC (permalink / raw)
To: intel-gfx
Cc: Chris Wilson, Sumit Semwal, Daniel Vetter, linux-media, dri-devel,
linaro-mm-sig
If we fail to create the anon file, we need to remember to release the
module reference on the owner.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linaro-mm-sig@lists.linaro.org
---
drivers/dma-buf/dma-buf.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 4a2c07ee6677..6f0f0b10a241 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -333,6 +333,7 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
struct reservation_object *resv = exp_info->resv;
struct file *file;
size_t alloc_size = sizeof(struct dma_buf);
+ int ret;
if (!exp_info->resv)
alloc_size += sizeof(struct reservation_object);
@@ -356,8 +357,8 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
dmabuf = kzalloc(alloc_size, GFP_KERNEL);
if (!dmabuf) {
- module_put(exp_info->owner);
- return ERR_PTR(-ENOMEM);
+ ret = -ENOMEM;
+ goto free_module;
}
dmabuf->priv = exp_info->priv;
@@ -378,8 +379,8 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
file = anon_inode_getfile("dmabuf", &dma_buf_fops, dmabuf,
exp_info->flags);
if (IS_ERR(file)) {
- kfree(dmabuf);
- return ERR_CAST(file);
+ ret = PTR_ERR(file);
+ goto free_dmabuf;
}
file->f_mode |= FMODE_LSEEK;
@@ -393,6 +394,12 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
mutex_unlock(&db_list.lock);
return dmabuf;
+
+free_dmabuf:
+ kfree(dmabuf);
+free_module:
+ module_put(exp_info->owner);
+ return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(dma_buf_export);
--
2.8.0.rc3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* ✗ Fi.CI.BAT: failure for dma-buf: Release module reference on creation failure
2016-03-31 8:35 [PATCH] dma-buf: Release module reference on creation failure Chris Wilson
@ 2016-03-31 16:14 ` Patchwork
2016-03-31 16:20 ` [Intel-gfx] [PATCH] " Joonas Lahtinen
1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2016-03-31 16:14 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: dma-buf: Release module reference on creation failure
URL : https://patchwork.freedesktop.org/series/5088/
State : failure
== Summary ==
Series 5088v1 dma-buf: Release module reference on creation failure
http://patchwork.freedesktop.org/api/1.0/series/5088/revisions/1/mbox/
Test gem_exec_suspend:
Subgroup basic-s3:
dmesg-warn -> PASS (bsw-nuc-2)
Test pm_rpm:
Subgroup basic-rte:
pass -> DMESG-WARN (bsw-nuc-2)
bdw-nuci7 total:196 pass:184 dwarn:0 dfail:0 fail:0 skip:12
bsw-nuc-2 total:196 pass:158 dwarn:1 dfail:0 fail:0 skip:37
byt-nuc total:196 pass:161 dwarn:0 dfail:0 fail:0 skip:35
hsw-brixbox total:196 pass:174 dwarn:0 dfail:0 fail:0 skip:22
hsw-gt2 total:55 pass:50 dwarn:0 dfail:0 fail:0 skip:4
skl-i7k-2 total:196 pass:173 dwarn:0 dfail:0 fail:0 skip:23
skl-nuci5 total:196 pass:185 dwarn:0 dfail:0 fail:0 skip:11
Results at /archive/results/CI_IGT_test/Patchwork_1763/
d42383d7815f4498871e8d73f10677cf1e48aa28 drm-intel-nightly: 2016y-03m-31d-14h-56m-52s UTC integration manifest
2823987be67a890e00b139d6cb255260af3d4a01 dma-buf: Release module reference on creation failure
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Intel-gfx] [PATCH] dma-buf: Release module reference on creation failure
2016-03-31 8:35 [PATCH] dma-buf: Release module reference on creation failure Chris Wilson
2016-03-31 16:14 ` ✗ Fi.CI.BAT: failure for " Patchwork
@ 2016-03-31 16:20 ` Joonas Lahtinen
1 sibling, 0 replies; 3+ messages in thread
From: Joonas Lahtinen @ 2016-03-31 16:20 UTC (permalink / raw)
To: Chris Wilson, intel-gfx
Cc: linaro-mm-sig, Daniel Vetter, dri-devel, linux-media
On to, 2016-03-31 at 09:35 +0100, Chris Wilson wrote:
> If we fail to create the anon file, we need to remember to release the
> module reference on the owner.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Sumit Semwal <sumit.semwal@linaro.org>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: linux-media@vger.kernel.org
> Cc: dri-devel@lists.freedesktop.org
> Cc: linaro-mm-sig@lists.linaro.org
> ---
> drivers/dma-buf/dma-buf.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 4a2c07ee6677..6f0f0b10a241 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -333,6 +333,7 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
> struct reservation_object *resv = exp_info->resv;
> struct file *file;
> size_t alloc_size = sizeof(struct dma_buf);
> + int ret;
>
> if (!exp_info->resv)
> alloc_size += sizeof(struct reservation_object);
> @@ -356,8 +357,8 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>
> dmabuf = kzalloc(alloc_size, GFP_KERNEL);
> if (!dmabuf) {
> - module_put(exp_info->owner);
> - return ERR_PTR(-ENOMEM);
> + ret = -ENOMEM;
> + goto free_module;
> }
>
> dmabuf->priv = exp_info->priv;
> @@ -378,8 +379,8 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
> file = anon_inode_getfile("dmabuf", &dma_buf_fops, dmabuf,
> exp_info->flags);
> if (IS_ERR(file)) {
> - kfree(dmabuf);
> - return ERR_CAST(file);
> + ret = PTR_ERR(file);
> + goto free_dmabuf;
> }
>
> file->f_mode |= FMODE_LSEEK;
> @@ -393,6 +394,12 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
> mutex_unlock(&db_list.lock);
>
> return dmabuf;
> +
> +free_dmabuf:
> + kfree(dmabuf);
> +free_module:
> + module_put(exp_info->owner);
> + return ERR_PTR(ret);
Labels could really be err_dmabuf (/ out_dmabuf). That's more in line
with rest of the codebase and kernel coding style: 'An example of a
good name could be "out_buffer:" if the goto frees "buffer".'
"free_dmabuf" does sound to me like it could also be executed on the
normal execution path of the function.
Other than that,
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> }
> EXPORT_SYMBOL_GPL(dma_buf_export);
>
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-31 16:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-31 8:35 [PATCH] dma-buf: Release module reference on creation failure Chris Wilson
2016-03-31 16:14 ` ✗ Fi.CI.BAT: failure for " Patchwork
2016-03-31 16:20 ` [Intel-gfx] [PATCH] " Joonas Lahtinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox