From: Dan Carpenter <dan.carpenter@oracle.com>
To: rafael.j.wysocki@intel.com
Cc: linux-acpi@vger.kernel.org
Subject: [bug report] ACPI: EC: Avoid passing redundant argument to functions
Date: Mon, 6 Apr 2020 17:42:17 +0300 [thread overview]
Message-ID: <20200406144217.GA68494@mwanda> (raw)
Hello Rafael J. Wysocki,
This is a semi-automatic email about new static checker warnings.
The patch a2b691772acd: "ACPI: EC: Avoid passing redundant argument
to functions" from Feb 27, 2020, leads to the following Smatch
complaint:
drivers/acpi/ec.c:1624 acpi_ec_add()
error: we previously assumed 'ec' could be null (see line 1595)
drivers/acpi/ec.c
1588
1589 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1590 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1591
1592 if ((boot_ec && boot_ec->handle == device->handle) ||
^^^^^^^
Assume "boot_ec" is NULL.
1593 !strcmp(acpi_device_hid(device), ACPI_ECDT_HID)) {
And the strings math.
1594 /* Fast path: this device corresponds to the boot EC. */
1595 ec = boot_ec;
^^^^^^^^^^^^
so "ec" is NULL.
1596 } else {
1597 acpi_status status;
1598
1599 ec = acpi_ec_alloc();
1600 if (!ec)
1601 return -ENOMEM;
1602
1603 status = ec_parse_device(device->handle, 0, ec, NULL);
1604 if (status != AE_CTRL_TERMINATE) {
1605 ret = -EINVAL;
1606 goto err;
1607 }
1608
1609 if (boot_ec && ec->command_addr == boot_ec->command_addr &&
1610 ec->data_addr == boot_ec->data_addr) {
1611 /*
1612 * Trust PNP0C09 namespace location rather than
1613 * ECDT ID. But trust ECDT GPE rather than _GPE
1614 * because of ASUS quirks, so do not change
1615 * boot_ec->gpe to ec->gpe.
1616 */
1617 boot_ec->handle = ec->handle;
1618 acpi_handle_debug(ec->handle, "duplicated.\n");
1619 acpi_ec_free(ec);
1620 ec = boot_ec;
1621 }
1622 }
1623
1624 ret = acpi_ec_setup(ec, device);
^^
NULL dereference inside the function.
1625 if (ret)
1626 goto err;
regards,
dan carpenter
reply other threads:[~2020-04-06 14:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200406144217.GA68494@mwanda \
--to=dan.carpenter@oracle.com \
--cc=linux-acpi@vger.kernel.org \
--cc=rafael.j.wysocki@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 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.