All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: kbuild-all@lists.01.org
Subject: Re: [hch-misc:dma_alloc_noncontiguous 3/10] drivers/media/common/videobuf2/videobuf2-dma-contig.c:188 vb2_dc_mmap() warn: variable dereferenced before check 'buf' (see line 185)
Date: Wed, 27 Jan 2021 13:32:13 +0100	[thread overview]
Message-ID: <20210127123213.GA5899@lst.de> (raw)
In-Reply-To: <YBFanTqnBh+hsWKd@jagdpanzerIV.localdomain>

[-- Attachment #1: Type: text/plain, Size: 3437 bytes --]

On Wed, Jan 27, 2021 at 09:20:45PM +0900, Sergey Senozhatsky wrote:
> On (21/01/27 08:58), Dan Carpenter wrote:
> > tree:   git://git.infradead.org/users/hch/misc.git dma_alloc_noncontiguous
> > head:   ecc175d8a7100071b073720d6729bb3f40dae639
> > commit: 6673227deba5cfc9c90084f49988e044a2ca2933 [3/10] WIP videobuf2: rework vb2_mem_ops API
> > config: x86_64-randconfig-m001-20210126 (attached as .config)
> > compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> > 
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > smatch warnings:
> > drivers/media/common/videobuf2/videobuf2-dma-contig.c:188 vb2_dc_mmap() warn: variable dereferenced before check 'buf' (see line 185)
> > 
> > vim +/buf +188 drivers/media/common/videobuf2/videobuf2-dma-contig.c
> > 
> > f7f129ce2e33f9 drivers/media/v4l2-core/videobuf2-dma-contig.c        Laurent Pinchart   2012-06-14  182  static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
> > 1a758d4e847f77 drivers/media/video/videobuf2-dma-contig.c            Pawel Osciak       2010-10-11  183  {
> > 1a758d4e847f77 drivers/media/video/videobuf2-dma-contig.c            Pawel Osciak       2010-10-11  184  	struct vb2_dc_buf *buf = buf_priv;
> > 6673227deba5cf drivers/media/common/videobuf2/videobuf2-dma-contig.c Sergey Senozhatsky 2020-11-27 @185  	struct vb2_queue *q = buf->vb->vb2_queue;
> >                                                                                                                                       ^^^^^
> > Dereference
> > 
> > c60520fa50cd86 drivers/media/v4l2-core/videobuf2-dma-contig.c        Marek Szyprowski   2012-06-14  186  	int ret;
> > 1a758d4e847f77 drivers/media/video/videobuf2-dma-contig.c            Pawel Osciak       2010-10-11  187  
> > 1a758d4e847f77 drivers/media/video/videobuf2-dma-contig.c            Pawel Osciak       2010-10-11 @188  	if (!buf) {
> >                                                                                                                     ^^^^
> > NULL check is too late.
> > 
> > 1a758d4e847f77 drivers/media/video/videobuf2-dma-contig.c            Pawel Osciak       2010-10-11  189  		printk(KERN_ERR "No buffer to map\n");
> > 1a758d4e847f77 drivers/media/video/videobuf2-dma-contig.c            Pawel Osciak       2010-10-11  190  		return -EINVAL;
> > 1a758d4e847f77 drivers/media/video/videobuf2-dma-contig.c            Pawel Osciak       2010-10-11  191  	}
> > 1a758d4e847f77 drivers/media/video/videobuf2-dma-contig.c            Pawel Osciak       2010-10-11  192  
> > 6673227deba5cf drivers/media/common/videobuf2/videobuf2-dma-contig.c Sergey Senozhatsky 2020-11-27  193  	ret = dma_mmap_attrs(buf->dev, vma, buf->cookie, buf->dma_addr,
> > 6673227deba5cf drivers/media/common/videobuf2/videobuf2-dma-contig.c Sergey Senozhatsky 2020-11-27  194  			     buf->size, q->dma_attrs);
> > c60520fa50cd86 drivers/media/v4l2-core/videobuf2-dma-contig.c        Marek Szyprowski   2012-06-14  195  	if (ret) {
> > c60520fa50cd86 drivers/media/v4l2-core/videobuf2-dma-contig.c        Marek Szyprowski   2012-06-14  196  		pr_err("Remapping memory failed, error: %d\n", ret);
> 
> Oh, yeah...
> 
> I'll take a look. My WIP branch is not really ready for the show yet.

Could also be that I messed it up when porting to the new API..

  reply	other threads:[~2021-01-27 12:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27  5:58 [hch-misc:dma_alloc_noncontiguous 3/10] drivers/media/common/videobuf2/videobuf2-dma-contig.c:188 vb2_dc_mmap() warn: variable dereferenced before check 'buf' (see line 185) Dan Carpenter
2021-01-27  5:58 ` Dan Carpenter
2021-01-27 12:20 ` Sergey Senozhatsky
2021-01-27 12:32   ` Christoph Hellwig [this message]
2021-01-27 15:41     ` Sergey Senozhatsky
  -- strict thread matches above, loose matches on Subject: below --
2021-01-26 22:58 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210127123213.GA5899@lst.de \
    --to=hch@lst.de \
    --cc=kbuild-all@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.