public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: kbuild@lists.01.org, lkp@intel.com, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org
Subject: Re: [jgunthorpe:vfio_ccw 7/12] drivers/vfio/mdev/mdev_core.c:319 mdev_device_create() warn: variable dereferenced before check 'drv' (see line 272)
Date: Wed, 15 Sep 2021 13:29:44 -0300	[thread overview]
Message-ID: <20210915162944.GM4065468@nvidia.com> (raw)
In-Reply-To: <202109150907.zXy9cIVX-lkp@intel.com>

On Wed, Sep 15, 2021 at 10:58:31AM +0300, Dan Carpenter wrote:
> tree:   https://github.com/jgunthorpe/linux vfio_ccw
> head:   d0d01fdc87368c19ee6cac8e7ab2c0ef7ab33efb
> commit: c7863bcc74538df3d39bd9407ae77f6ef778f7b3 [7/12] vfio/mdev: Add mdev available instance checking to the core
> config: x86_64-randconfig-m001-20210914 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 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/vfio/mdev/mdev_core.c:319 mdev_device_create() warn: variable dereferenced before check 'drv' (see line 272)
> 
> vim +/drv +319 drivers/vfio/mdev/mdev_core.c
> 
> 417fd5bf242d76 Jason Gunthorpe 2021-04-06  255  int mdev_device_create(struct mdev_type *type, const guid_t *uuid)
> 7b96953bc640b6 Kirti Wankhede  2016-11-17  256  {
> 7b96953bc640b6 Kirti Wankhede  2016-11-17  257  	int ret;
> 002fe996f67f4f Alex Williamson 2018-05-15  258  	struct mdev_device *mdev, *tmp;
> a9f8111d0b5f44 Jason Gunthorpe 2021-04-06  259  	struct mdev_parent *parent = type->parent;
> 88a21f265ce50a Jason Gunthorpe 2021-06-17  260  	struct mdev_driver *drv = parent->ops->device_driver;
> 7b96953bc640b6 Kirti Wankhede  2016-11-17  261  
> 002fe996f67f4f Alex Williamson 2018-05-15  262  	mutex_lock(&mdev_list_lock);
> 7b96953bc640b6 Kirti Wankhede  2016-11-17  263  
> 7b96953bc640b6 Kirti Wankhede  2016-11-17  264  	/* Check for duplicate */
> 002fe996f67f4f Alex Williamson 2018-05-15  265  	list_for_each_entry(tmp, &mdev_list, next) {
> 278bca7f318e6a Andy Shevchenko 2019-01-10  266  		if (guid_equal(&tmp->uuid, uuid)) {
> 002fe996f67f4f Alex Williamson 2018-05-15  267  			mutex_unlock(&mdev_list_lock);
> fbd0e2b0c3d0b2 Jason Gunthorpe 2021-04-06  268  			return -EEXIST;
> 002fe996f67f4f Alex Williamson 2018-05-15  269  		}
> 7b96953bc640b6 Kirti Wankhede  2016-11-17  270  	}
> 7b96953bc640b6 Kirti Wankhede  2016-11-17  271  
> c7863bcc74538d Jason Gunthorpe 2021-09-07 @272  	if (drv->get_available) {
>                                                             ^^^^^^^^^^^^^^^^^^
> Dereference

woops, got it, thanks Dan

Jason

      reply	other threads:[~2021-09-15 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15  7:58 [jgunthorpe:vfio_ccw 7/12] drivers/vfio/mdev/mdev_core.c:319 mdev_device_create() warn: variable dereferenced before check 'drv' (see line 272) Dan Carpenter
2021-09-15 16:29 ` Jason Gunthorpe [this message]

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=20210915162944.GM4065468@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox