Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1629641

Re: [PATCH 2/2] [media] vb2: Fix error handling in '__vb2_buf_mem_alloc'

From Sakari Ailus <sakari.ailus@iki.fi>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] [media] vb2: Fix error handling in '__vb2_buf_mem_alloc'
Date 2017-04-24 16:30 +0200
Message-ID <tzNa4-87g-57@gated-at.bofh.it> (permalink)
References <tzxyh-5K2-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Christophe,

On Sun, Apr 23, 2017 at 11:40:30PM +0200, Christophe JAILLET wrote:
> 'call_ptr_memop' can return NULL, so we must test its return value with
> 'IS_ERR_OR_NULL'. Otherwise, the test 'if (mem_priv)' is meaningless.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Note that error checking after 'call_ptr_memop' calls is not consistent
> in this file. I guess that 'IS_ERR_OR_NULL' should be used everywhere
> and that the corresponding error handling code should be tweaked just as
> the code in this function.
> ---
>  drivers/media/v4l2-core/videobuf2-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index c0175ea7e7ad..d1d3f5dd57b9 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -210,7 +210,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
>  		mem_priv = call_ptr_memop(vb, alloc,
>  				q->alloc_devs[plane] ? : q->dev,
>  				q->dma_attrs, size, dma_dir, q->gfp_flags);
> -		if (IS_ERR(mem_priv)) {
> +		if (IS_ERR_OR_NULL(mem_priv)) {
>  			if (mem_priv)
>  				ret = PTR_ERR(mem_priv);
>  			goto free;

If NULL will always equate -ENOMEM, shouldn't call_ptr_memop() be changed
instead to convert NULL to ERR_PTR(-ENOMEM)?

-- 
Regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/2] [media] vb2: Fix error handling in '__vb2_buf_mem_alloc' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-04-23 23:50 +0200
  Re: [PATCH 2/2] [media] vb2: Fix error handling in  '__vb2_buf_mem_alloc' Sakari Ailus <sakari.ailus@iki.fi> - 2017-04-24 16:30 +0200
    Re: [PATCH 2/2] [media] vb2: Fix error handling in  '__vb2_buf_mem_alloc' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-04-24 22:30 +0200
      Re: [PATCH 2/2] [media] vb2: Fix error handling in  '__vb2_buf_mem_alloc' Sakari Ailus <sakari.ailus@iki.fi> - 2017-04-24 22:50 +0200

csiph-web