software node: Initialize the return value in software_node_to_swnode()
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Fri, 30 Aug 2019 07:51:55 +0000 (10:51 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 4 Sep 2019 21:03:19 +0000 (23:03 +0200)
The software node is searched from a list that may be empty
when the function is called. This makes sure that the
function returns NULL even if the list is empty.

Fixes: 80488a6b1d3c ("software node: Add support for static node descriptors")
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/swnode.c

index ee2a405cca9a242bb912a7783001321dd3b6ab48..1838d72e618af0aac48f4da82d6f94ba8e31d1fa 100644 (file)
@@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(is_software_node);
 static struct swnode *
 software_node_to_swnode(const struct software_node *node)
 {
-       struct swnode *swnode;
+       struct swnode *swnode = NULL;
        struct kobject *k;
 
        if (!node)