[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181107043933.wqszrfajrfy6hv7u@mwanda>
Date: Wed, 7 Nov 2018 07:39:33 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: kbuild@...org, Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc: kbuild-all@...org, "Rafael J. Wysocki" <rjw@...ysocki.net>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Linus Walleij <linus.walleij@...aro.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org
Subject: Re: [PATCH 4/6] drivers: base: Introducing software nodes to the
firmware node framework
Hi Heikki,
url: https://github.com/0day-ci/linux/commits/Heikki-Krogerus/device-property-Introducing-software-nodes/20181106-031310
smatch warnings:
drivers/base/swnode.c:391 fwnode_create_software_node() error: dereferencing freed memory 'swnode'
# https://github.com/0day-ci/linux/commit/a8c9678ea46a0171baed68e4ec355a9b3f967458
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout a8c9678ea46a0171baed68e4ec355a9b3f967458
vim +/swnode +391 drivers/base/swnode.c
a8c9678e Heikki Krogerus 2018-11-05 365
a8c9678e Heikki Krogerus 2018-11-05 366 struct fwnode_handle *
a8c9678e Heikki Krogerus 2018-11-05 367 fwnode_create_software_node(const struct property_entry *properties,
a8c9678e Heikki Krogerus 2018-11-05 368 const struct fwnode_handle *parent)
a8c9678e Heikki Krogerus 2018-11-05 369 {
a8c9678e Heikki Krogerus 2018-11-05 370 struct software_node *p = NULL;
a8c9678e Heikki Krogerus 2018-11-05 371 struct software_node *swnode;
a8c9678e Heikki Krogerus 2018-11-05 372 char node_name[20];
a8c9678e Heikki Krogerus 2018-11-05 373 int ret;
a8c9678e Heikki Krogerus 2018-11-05 374
a8c9678e Heikki Krogerus 2018-11-05 375 if (parent) {
a8c9678e Heikki Krogerus 2018-11-05 376 if (IS_ERR(parent))
a8c9678e Heikki Krogerus 2018-11-05 377 return ERR_CAST(parent);
a8c9678e Heikki Krogerus 2018-11-05 378 if (!is_software_node(parent))
a8c9678e Heikki Krogerus 2018-11-05 379 return ERR_PTR(-EINVAL);
a8c9678e Heikki Krogerus 2018-11-05 380 p = to_software_node(parent);
a8c9678e Heikki Krogerus 2018-11-05 381 }
a8c9678e Heikki Krogerus 2018-11-05 382
a8c9678e Heikki Krogerus 2018-11-05 383 swnode = kzalloc(sizeof(*swnode), GFP_KERNEL);
a8c9678e Heikki Krogerus 2018-11-05 384 if (!swnode)
a8c9678e Heikki Krogerus 2018-11-05 385 return ERR_PTR(-ENOMEM);
a8c9678e Heikki Krogerus 2018-11-05 386
a8c9678e Heikki Krogerus 2018-11-05 387 swnode->id = ida_simple_get(p ? &p->child_ids : &swnode_root_ids, 0, 0,
a8c9678e Heikki Krogerus 2018-11-05 388 GFP_KERNEL);
a8c9678e Heikki Krogerus 2018-11-05 389 if (swnode->id < 0) {
a8c9678e Heikki Krogerus 2018-11-05 390 kfree(swnode);
^^^^^^
a8c9678e Heikki Krogerus 2018-11-05 @391 return ERR_PTR(swnode->id);
^^^^^^^^^^
a8c9678e Heikki Krogerus 2018-11-05 392 }
a8c9678e Heikki Krogerus 2018-11-05 393
a8c9678e Heikki Krogerus 2018-11-05 394 sprintf(node_name, "node%d", swnode->id);
a8c9678e Heikki Krogerus 2018-11-05 395
a8c9678e Heikki Krogerus 2018-11-05 396 swnode->kobj.kset = swnode_kset;
a8c9678e Heikki Krogerus 2018-11-05 397 swnode->fwnode.ops = &software_node_ops;
a8c9678e Heikki Krogerus 2018-11-05 398
a8c9678e Heikki Krogerus 2018-11-05 399 ida_init(&swnode->child_ids);
a8c9678e Heikki Krogerus 2018-11-05 400 INIT_LIST_HEAD(&swnode->entry);
a8c9678e Heikki Krogerus 2018-11-05 401 INIT_LIST_HEAD(&swnode->children);
a8c9678e Heikki Krogerus 2018-11-05 402 swnode->parent = p;
a8c9678e Heikki Krogerus 2018-11-05 403
a8c9678e Heikki Krogerus 2018-11-05 404 if (p)
a8c9678e Heikki Krogerus 2018-11-05 405 list_add_tail(&swnode->entry, &p->children);
a8c9678e Heikki Krogerus 2018-11-05 406
a8c9678e Heikki Krogerus 2018-11-05 407 ret = kobject_init_and_add(&swnode->kobj, &software_node_type,
a8c9678e Heikki Krogerus 2018-11-05 408 p ? &p->kobj : NULL, node_name);
a8c9678e Heikki Krogerus 2018-11-05 409 if (ret) {
a8c9678e Heikki Krogerus 2018-11-05 410 kobject_put(&swnode->kobj);
a8c9678e Heikki Krogerus 2018-11-05 411 return ERR_PTR(ret);
a8c9678e Heikki Krogerus 2018-11-05 412 }
a8c9678e Heikki Krogerus 2018-11-05 413
a8c9678e Heikki Krogerus 2018-11-05 414 ret = software_node_register_properties(swnode, properties);
a8c9678e Heikki Krogerus 2018-11-05 415 if (ret) {
a8c9678e Heikki Krogerus 2018-11-05 416 kobject_put(&swnode->kobj);
a8c9678e Heikki Krogerus 2018-11-05 417 return ERR_PTR(ret);
a8c9678e Heikki Krogerus 2018-11-05 418 }
a8c9678e Heikki Krogerus 2018-11-05 419
a8c9678e Heikki Krogerus 2018-11-05 420 kobject_uevent(&swnode->kobj, KOBJ_ADD);
a8c9678e Heikki Krogerus 2018-11-05 421 return &swnode->fwnode;
a8c9678e Heikki Krogerus 2018-11-05 422 }
a8c9678e Heikki Krogerus 2018-11-05 423 EXPORT_SYMBOL_GPL(fwnode_create_software_node);
a8c9678e Heikki Krogerus 2018-11-05 424
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Powered by blists - more mailing lists