From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mika Westerberg Subject: Re: [PATCH] ACPI / PM: Fix error code path for power resources initialization Date: Wed, 19 Jun 2013 10:29:56 +0300 Message-ID: <20130619072956.GE11878@intel.com> References: <8547354.D2OPcUytEB@vostro.rjw.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <8547354.D2OPcUytEB@vostro.rjw.lan> Sender: linux-pm-owner@vger.kernel.org To: "Rafael J. Wysocki" Cc: ACPI Devel Maling List , LKML , Linux PM list List-Id: linux-acpi@vger.kernel.org On Tue, Jun 18, 2013 at 12:37:45AM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Commit 781d737 (ACPI: Drop power resources driver) introduced a > bug in the power resources initialization error code path causing > a NULL pointer to be referenced in acpi_release_power_resource() > if there's an error triggering a jump to the 'err' label in > acpi_add_power_resource(). This happens because the list_node > field of struct acpi_power_resource has not been initialized yet > at this point and doing a list_del() on it is a bad idea. > > To prevent this problem from occuring, initialize the list_node > field of struct acpi_power_resource upfront. > > Reported-by: Mika Westerberg Reviewed-by: Mika Westerberg > Signed-off-by: Rafael J. Wysocki > Cc: 3.9+ > --- > drivers/acpi/power.c | 1 + > 1 file changed, 1 insertion(+) > > Index: linux-pm/drivers/acpi/power.c > =================================================================== > --- linux-pm.orig/drivers/acpi/power.c > +++ linux-pm/drivers/acpi/power.c > @@ -882,6 +882,7 @@ int acpi_add_power_resource(acpi_handle > ACPI_STA_DEFAULT); > mutex_init(&resource->resource_lock); > INIT_LIST_HEAD(&resource->dependent); > + INIT_LIST_HEAD(&resource->list_node); > resource->name = device->pnp.bus_id; > strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); > strcpy(acpi_device_class(device), ACPI_POWER_CLASS);