All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf: Release module reference on creation failure
@ 2016-07-18 11:16 Chris Wilson
  2016-07-18 12:05 ` ✓ Ro.CI.BAT: success for dma-buf: Release module reference on creation failure (rev2) Patchwork
  2016-07-18 12:10   ` Daniel Vetter
  0 siblings, 2 replies; 7+ messages in thread
From: Chris Wilson @ 2016-07-18 11:16 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Chris Wilson, Joonas Lahtinen, Sumit Semwal,
	Daniel Vetter, linux-media, 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>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
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 20ce0687b111..ddaee60ae52a 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -334,6 +334,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);
@@ -357,8 +358,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 err_module;
 	}
 
 	dmabuf->priv = exp_info->priv;
@@ -379,8 +380,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 err_dmabuf;
 	}
 
 	file->f_mode |= FMODE_LSEEK;
@@ -394,6 +395,12 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
 	mutex_unlock(&db_list.lock);
 
 	return dmabuf;
+
+err_dmabuf:
+	kfree(dmabuf);
+err_module:
+	module_put(exp_info->owner);
+	return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(dma_buf_export);
 
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* ✓ Ro.CI.BAT: success for dma-buf: Release module reference on creation failure (rev2)
  2016-07-18 11:16 [PATCH] dma-buf: Release module reference on creation failure Chris Wilson
@ 2016-07-18 12:05 ` Patchwork
  2016-07-18 12:10   ` Daniel Vetter
  1 sibling, 0 replies; 7+ messages in thread
From: Patchwork @ 2016-07-18 12:05 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: dma-buf: Release module reference on creation failure (rev2)
URL   : https://patchwork.freedesktop.org/series/5088/
State : success

== Summary ==

Series 5088v2 dma-buf: Release module reference on creation failure
http://patchwork.freedesktop.org/api/1.0/series/5088/revisions/2/mbox


fi-hsw-i7-4770k  total:242  pass:210  dwarn:0   dfail:0   fail:12  skip:20 
fi-kbl-qkkr      total:242  pass:176  dwarn:23  dfail:3   fail:13  skip:27 
fi-skl-i5-6260u  total:242  pass:219  dwarn:0   dfail:0   fail:11  skip:12 
fi-snb-i7-2600   total:242  pass:190  dwarn:0   dfail:0   fail:12  skip:40 
ro-bdw-i5-5250u  total:243  pass:214  dwarn:4   dfail:0   fail:12  skip:13 
ro-bdw-i7-5557U  total:243  pass:215  dwarn:1   dfail:0   fail:12  skip:15 
ro-bdw-i7-5600u  total:243  pass:200  dwarn:0   dfail:0   fail:11  skip:32 
ro-bsw-n3050     total:218  pass:173  dwarn:0   dfail:0   fail:2   skip:42 
ro-byt-n2820     total:243  pass:191  dwarn:0   dfail:0   fail:14  skip:38 
ro-hsw-i3-4010u  total:243  pass:206  dwarn:0   dfail:0   fail:13  skip:24 
ro-hsw-i7-4770r  total:243  pass:206  dwarn:0   dfail:0   fail:13  skip:24 
ro-ilk-i7-620lm  total:243  pass:166  dwarn:0   dfail:0   fail:14  skip:63 
ro-ilk1-i5-650   total:238  pass:166  dwarn:0   dfail:0   fail:14  skip:58 
ro-ivb-i7-3770   total:243  pass:197  dwarn:0   dfail:0   fail:13  skip:33 
ro-skl3-i5-6260u total:243  pass:218  dwarn:1   dfail:0   fail:12  skip:12 
ro-snb-i7-2620M  total:243  pass:188  dwarn:0   dfail:0   fail:13  skip:42 
fi-bsw-n3050 failed to connect after reboot
fi-skl-i7-6700k failed to connect after reboot

Results at /archive/results/CI_IGT_test/RO_Patchwork_1518/

74bd981 drm-intel-nightly: 2016y-07m-18d-10h-05m-42s UTC integration manifest
9ab0258 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] 7+ messages in thread

* Re: [PATCH] dma-buf: Release module reference on creation failure
  2016-07-18 11:16 [PATCH] dma-buf: Release module reference on creation failure Chris Wilson
@ 2016-07-18 12:10   ` Daniel Vetter
  2016-07-18 12:10   ` Daniel Vetter
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2016-07-18 12:10 UTC (permalink / raw)
  To: Chris Wilson
  Cc: dri-devel, intel-gfx, Joonas Lahtinen, Sumit Semwal,
	Daniel Vetter, linux-media, linaro-mm-sig

On Mon, Jul 18, 2016 at 12:16:22PM +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>
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> 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 20ce0687b111..ddaee60ae52a 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -334,6 +334,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;

Not sure this really helps readability, but meh. Will apply to drm-misc,
with a cc: stable.
-Daniel

>  
>  	if (!exp_info->resv)
>  		alloc_size += sizeof(struct reservation_object);
> @@ -357,8 +358,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 err_module;
>  	}
>  
>  	dmabuf->priv = exp_info->priv;
> @@ -379,8 +380,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 err_dmabuf;
>  	}
>  
>  	file->f_mode |= FMODE_LSEEK;
> @@ -394,6 +395,12 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>  	mutex_unlock(&db_list.lock);
>  
>  	return dmabuf;
> +
> +err_dmabuf:
> +	kfree(dmabuf);
> +err_module:
> +	module_put(exp_info->owner);
> +	return ERR_PTR(ret);
>  }
>  EXPORT_SYMBOL_GPL(dma_buf_export);
>  
> -- 
> 2.8.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dma-buf: Release module reference on creation failure
@ 2016-07-18 12:10   ` Daniel Vetter
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2016-07-18 12:10 UTC (permalink / raw)
  To: Chris Wilson
  Cc: Daniel Vetter, intel-gfx, dri-devel, linaro-mm-sig, Sumit Semwal,
	linux-media

On Mon, Jul 18, 2016 at 12:16:22PM +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>
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> 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 20ce0687b111..ddaee60ae52a 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -334,6 +334,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;

Not sure this really helps readability, but meh. Will apply to drm-misc,
with a cc: stable.
-Daniel

>  
>  	if (!exp_info->resv)
>  		alloc_size += sizeof(struct reservation_object);
> @@ -357,8 +358,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 err_module;
>  	}
>  
>  	dmabuf->priv = exp_info->priv;
> @@ -379,8 +380,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 err_dmabuf;
>  	}
>  
>  	file->f_mode |= FMODE_LSEEK;
> @@ -394,6 +395,12 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>  	mutex_unlock(&db_list.lock);
>  
>  	return dmabuf;
> +
> +err_dmabuf:
> +	kfree(dmabuf);
> +err_module:
> +	module_put(exp_info->owner);
> +	return ERR_PTR(ret);
>  }
>  EXPORT_SYMBOL_GPL(dma_buf_export);
>  
> -- 
> 2.8.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dma-buf: Release module reference on creation failure
  2016-07-18 12:10   ` Daniel Vetter
@ 2016-07-18 13:03     ` Sumit Semwal
  -1 siblings, 0 replies; 7+ messages in thread
From: Sumit Semwal @ 2016-07-18 13:03 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Chris Wilson, DRI mailing list, intel-gfx, Joonas Lahtinen,
	Daniel Vetter, linux-media, Linaro MM SIG Mailman List

Hi Chris,

On 18 July 2016 at 17:40, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Mon, Jul 18, 2016 at 12:16:22PM +0100, Chris Wilson wrote:
>> If we fail to create the anon file, we need to remember to release the
>> module reference on the owner.
>>
Thanks for the patch.

>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> 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 20ce0687b111..ddaee60ae52a 100644
>> --- a/drivers/dma-buf/dma-buf.c
>> +++ b/drivers/dma-buf/dma-buf.c
>> @@ -334,6 +334,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;
>
> Not sure this really helps readability, but meh. Will apply to drm-misc,
> with a cc: stable.
Daniel, fwiw, please feel free to add
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>

> -Daniel

BR,
~Sumit.
>
>>
>>       if (!exp_info->resv)
>>               alloc_size += sizeof(struct reservation_object);
>> @@ -357,8 +358,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 err_module;
>>       }
>>
>>       dmabuf->priv = exp_info->priv;
>> @@ -379,8 +380,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 err_dmabuf;
>>       }
>>
>>       file->f_mode |= FMODE_LSEEK;
>> @@ -394,6 +395,12 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>>       mutex_unlock(&db_list.lock);
>>
>>       return dmabuf;
>> +
>> +err_dmabuf:
>> +     kfree(dmabuf);
>> +err_module:
>> +     module_put(exp_info->owner);
>> +     return ERR_PTR(ret);
>>  }
>>  EXPORT_SYMBOL_GPL(dma_buf_export);
>>
>> --
>> 2.8.1
>>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch



-- 
Thanks and regards,

Sumit Semwal
Linaro Mobile Group - Kernel Team Lead
Linaro.org │ Open source software for ARM SoCs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] dma-buf: Release module reference on creation failure
@ 2016-07-18 13:03     ` Sumit Semwal
  0 siblings, 0 replies; 7+ messages in thread
From: Sumit Semwal @ 2016-07-18 13:03 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Daniel Vetter, intel-gfx, DRI mailing list,
	Linaro MM SIG Mailman List, linux-media

Hi Chris,

On 18 July 2016 at 17:40, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Mon, Jul 18, 2016 at 12:16:22PM +0100, Chris Wilson wrote:
>> If we fail to create the anon file, we need to remember to release the
>> module reference on the owner.
>>
Thanks for the patch.

>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> 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 20ce0687b111..ddaee60ae52a 100644
>> --- a/drivers/dma-buf/dma-buf.c
>> +++ b/drivers/dma-buf/dma-buf.c
>> @@ -334,6 +334,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;
>
> Not sure this really helps readability, but meh. Will apply to drm-misc,
> with a cc: stable.
Daniel, fwiw, please feel free to add
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>

> -Daniel

BR,
~Sumit.
>
>>
>>       if (!exp_info->resv)
>>               alloc_size += sizeof(struct reservation_object);
>> @@ -357,8 +358,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 err_module;
>>       }
>>
>>       dmabuf->priv = exp_info->priv;
>> @@ -379,8 +380,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 err_dmabuf;
>>       }
>>
>>       file->f_mode |= FMODE_LSEEK;
>> @@ -394,6 +395,12 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
>>       mutex_unlock(&db_list.lock);
>>
>>       return dmabuf;
>> +
>> +err_dmabuf:
>> +     kfree(dmabuf);
>> +err_module:
>> +     module_put(exp_info->owner);
>> +     return ERR_PTR(ret);
>>  }
>>  EXPORT_SYMBOL_GPL(dma_buf_export);
>>
>> --
>> 2.8.1
>>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch



-- 
Thanks and regards,

Sumit Semwal
Linaro Mobile Group - Kernel Team Lead
Linaro.org │ Open source software for ARM SoCs
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] dma-buf: Release module reference on creation failure
@ 2016-03-31  8:35 Chris Wilson
  0 siblings, 0 replies; 7+ 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] 7+ messages in thread

end of thread, other threads:[~2016-07-18 13:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-18 11:16 [PATCH] dma-buf: Release module reference on creation failure Chris Wilson
2016-07-18 12:05 ` ✓ Ro.CI.BAT: success for dma-buf: Release module reference on creation failure (rev2) Patchwork
2016-07-18 12:10 ` [PATCH] dma-buf: Release module reference on creation failure Daniel Vetter
2016-07-18 12:10   ` Daniel Vetter
2016-07-18 13:03   ` Sumit Semwal
2016-07-18 13:03     ` Sumit Semwal
  -- strict thread matches above, loose matches on Subject: below --
2016-03-31  8:35 Chris Wilson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.