All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] ACPI: EC: Avoid passing redundant argument to functions
@ 2020-04-06 14:42 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2020-04-06 14:42 UTC (permalink / raw)
  To: rafael.j.wysocki; +Cc: linux-acpi

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-06 14:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-06 14:42 [bug report] ACPI: EC: Avoid passing redundant argument to functions Dan Carpenter

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.