[pm:bleeding-edge 75/85] drivers/base/swnode.c:587:23-27: ERROR: swnode is NULL but dereferenced. (fwd)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

The problem appears to be on line 551.  swnode can't be NULL after the
lock is taken.  Perhaps the test is just not needed, or perhaps something
else was intended to be checked.

julia

---------- Forwarded message ----------
Date: Wed, 17 Apr 2019 08:37:13 +0800
From: kbuild test robot <lkp@xxxxxxxxx>
To: kbuild@xxxxxx
Cc: Julia Lawall <julia.lawall@xxxxxxx>
Subject: [pm:bleeding-edge 75/85] drivers/base/swnode.c:587:23-27: ERROR: swnode
     is NULL but dereferenced.

CC: kbuild-all@xxxxxx
CC: linux-acpi@xxxxxxxxxxxxxxx
CC: devel@xxxxxxxxxx
CC: linux-pm@xxxxxxxxxxxxxxx
TO: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
CC: "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git bleeding-edge
head:   98438d88cbe65037744bdc071720389797f9c575
commit: 7b68d5fe9581aed81d84280891f9a8b1508c911b [75/85] software node: Implement .get_reference_args fwnode operation
:::::: branch date: 3 hours ago
:::::: commit date: 3 hours ago

>> drivers/base/swnode.c:587:23-27: ERROR: swnode is NULL but dereferenced.

# https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/commit/?id=7b68d5fe9581aed81d84280891f9a8b1508c911b
git remote add pm https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
git remote update pm
git checkout 7b68d5fe9581aed81d84280891f9a8b1508c911b
vim +587 drivers/base/swnode.c

59abd836 Heikki Krogerus 2018-11-09  536
7b68d5fe Heikki Krogerus 2019-04-12  537  static int
7b68d5fe Heikki Krogerus 2019-04-12  538  software_node_get_reference_args(const struct fwnode_handle *fwnode,
7b68d5fe Heikki Krogerus 2019-04-12  539  				 const char *propname, const char *nargs_prop,
7b68d5fe Heikki Krogerus 2019-04-12  540  				 unsigned int nargs, unsigned int index,
7b68d5fe Heikki Krogerus 2019-04-12  541  				 struct fwnode_reference_args *args)
7b68d5fe Heikki Krogerus 2019-04-12  542  {
7b68d5fe Heikki Krogerus 2019-04-12  543  	struct software_node *swnode = to_software_node(fwnode);
7b68d5fe Heikki Krogerus 2019-04-12  544  	struct software_node_reference *ref;
7b68d5fe Heikki Krogerus 2019-04-12  545  	const struct property_entry *prop;
7b68d5fe Heikki Krogerus 2019-04-12  546  	int ret = -ENOENT;
7b68d5fe Heikki Krogerus 2019-04-12  547  	int i;
7b68d5fe Heikki Krogerus 2019-04-12  548
7b68d5fe Heikki Krogerus 2019-04-12  549  	mutex_lock(&swnode->lock);
7b68d5fe Heikki Krogerus 2019-04-12  550
7b68d5fe Heikki Krogerus 2019-04-12  551  	if (!swnode || list_empty(&swnode->references))
7b68d5fe Heikki Krogerus 2019-04-12  552  		goto err_unlock;
7b68d5fe Heikki Krogerus 2019-04-12  553
7b68d5fe Heikki Krogerus 2019-04-12  554  	if (nargs_prop) {
7b68d5fe Heikki Krogerus 2019-04-12  555  		prop = property_entry_get(swnode->properties, nargs_prop);
7b68d5fe Heikki Krogerus 2019-04-12  556  		if (!prop) {
7b68d5fe Heikki Krogerus 2019-04-12  557  			ret = -EINVAL;
7b68d5fe Heikki Krogerus 2019-04-12  558  			goto err_unlock;
7b68d5fe Heikki Krogerus 2019-04-12  559  		}
7b68d5fe Heikki Krogerus 2019-04-12  560
7b68d5fe Heikki Krogerus 2019-04-12  561  		nargs = prop->value.u32_data;
7b68d5fe Heikki Krogerus 2019-04-12  562  	}
7b68d5fe Heikki Krogerus 2019-04-12  563
7b68d5fe Heikki Krogerus 2019-04-12  564  	if (nargs > NR_FWNODE_REFERENCE_ARGS) {
7b68d5fe Heikki Krogerus 2019-04-12  565  		ret = -EINVAL;
7b68d5fe Heikki Krogerus 2019-04-12  566  		goto err_unlock;
7b68d5fe Heikki Krogerus 2019-04-12  567  	}
7b68d5fe Heikki Krogerus 2019-04-12  568
7b68d5fe Heikki Krogerus 2019-04-12  569  	list_for_each_entry(ref, &swnode->references, list) {
7b68d5fe Heikki Krogerus 2019-04-12  570  		if (strcmp(ref->name, propname))
7b68d5fe Heikki Krogerus 2019-04-12  571  			continue;
7b68d5fe Heikki Krogerus 2019-04-12  572
7b68d5fe Heikki Krogerus 2019-04-12  573  		if (index > (ref->nrefs - 1))
7b68d5fe Heikki Krogerus 2019-04-12  574  			break;
7b68d5fe Heikki Krogerus 2019-04-12  575
7b68d5fe Heikki Krogerus 2019-04-12  576  		args->nargs = nargs;
7b68d5fe Heikki Krogerus 2019-04-12  577  		args->fwnode = software_node_get(ref->args[index].fwnode);
7b68d5fe Heikki Krogerus 2019-04-12  578
7b68d5fe Heikki Krogerus 2019-04-12  579  		for (i = 0; i < nargs; i++)
7b68d5fe Heikki Krogerus 2019-04-12  580  			args->args[i] = ref->args[index].args[i];
7b68d5fe Heikki Krogerus 2019-04-12  581
7b68d5fe Heikki Krogerus 2019-04-12  582  		ret = 0;
7b68d5fe Heikki Krogerus 2019-04-12  583  		break;
7b68d5fe Heikki Krogerus 2019-04-12  584  	}
7b68d5fe Heikki Krogerus 2019-04-12  585
7b68d5fe Heikki Krogerus 2019-04-12  586  err_unlock:
7b68d5fe Heikki Krogerus 2019-04-12 @587  	mutex_unlock(&swnode->lock);
7b68d5fe Heikki Krogerus 2019-04-12  588
7b68d5fe Heikki Krogerus 2019-04-12  589  	return ret;
7b68d5fe Heikki Krogerus 2019-04-12  590  }
7b68d5fe Heikki Krogerus 2019-04-12  591

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux