From mboxrd@z Thu Jan 1 00:00:00 1970 From: Colin Cross Subject: [PATCHv2 2/5] cpuidle: fix error handling in __cpuidle_register_device Date: Wed, 14 Mar 2012 11:29:51 -0700 Message-ID: <1331749794-8056-3-git-send-email-ccross@android.com> References: <1331749794-8056-1-git-send-email-ccross@android.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1331749794-8056-1-git-send-email-ccross@android.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org To: linux-kernel@vger.kernel.org Cc: Kevin Hilman , Len Brown , Kay Sievers , Greg Kroah-Hartman , Amit Kucheria , Colin Cross , linux-pm@lists.linux-foundation.org, Arjan van de Ven , linux-arm-kernel@lists.infradead.org List-Id: linux-pm@vger.kernel.org Fix the error handling in __cpuidle_register_device to include the missing list_del. Move it to a label, which will simplify the error handling when coupled states are added. Signed-off-by: Colin Cross --- drivers/cpuidle/cpuidle.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) v2: * fix after rename of sys_dev to cpu_dev * reorder error path to reverse of probe path diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 1453830..aacf2f0 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -319,13 +319,18 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) per_cpu(cpuidle_devices, dev->cpu) = dev; list_add(&dev->device_list, &cpuidle_detected_devices); - if ((ret = cpuidle_add_sysfs(cpu_dev))) { - module_put(cpuidle_driver->owner); - return ret; - } + ret = cpuidle_add_sysfs(cpu_dev); + if (ret) + goto err_sysfs; dev->registered = 1; return 0; + +err_sysfs: + list_del(&dev->device_list); + per_cpu(cpuidle_devices, dev->cpu) = NULL; + module_put(cpuidle_driver->owner); + return ret; } /** -- 1.7.9.2 From mboxrd@z Thu Jan 1 00:00:00 1970 From: ccross@android.com (Colin Cross) Date: Wed, 14 Mar 2012 11:29:51 -0700 Subject: [PATCHv2 2/5] cpuidle: fix error handling in __cpuidle_register_device In-Reply-To: <1331749794-8056-1-git-send-email-ccross@android.com> References: <1331749794-8056-1-git-send-email-ccross@android.com> Message-ID: <1331749794-8056-3-git-send-email-ccross@android.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Fix the error handling in __cpuidle_register_device to include the missing list_del. Move it to a label, which will simplify the error handling when coupled states are added. Signed-off-by: Colin Cross --- drivers/cpuidle/cpuidle.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) v2: * fix after rename of sys_dev to cpu_dev * reorder error path to reverse of probe path diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 1453830..aacf2f0 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -319,13 +319,18 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) per_cpu(cpuidle_devices, dev->cpu) = dev; list_add(&dev->device_list, &cpuidle_detected_devices); - if ((ret = cpuidle_add_sysfs(cpu_dev))) { - module_put(cpuidle_driver->owner); - return ret; - } + ret = cpuidle_add_sysfs(cpu_dev); + if (ret) + goto err_sysfs; dev->registered = 1; return 0; + +err_sysfs: + list_del(&dev->device_list); + per_cpu(cpuidle_devices, dev->cpu) = NULL; + module_put(cpuidle_driver->owner); + return ret; } /** -- 1.7.9.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757896Ab2CNSaG (ORCPT ); Wed, 14 Mar 2012 14:30:06 -0400 Received: from mail-yx0-f202.google.com ([209.85.213.202]:52899 "EHLO mail-yx0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755156Ab2CNSaA (ORCPT ); Wed, 14 Mar 2012 14:30:00 -0400 From: Colin Cross To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-pm@lists.linux-foundation.org, Kevin Hilman , Len Brown , Trinabh Gupta , Arjan van de Ven , Deepthi Dharwar , Greg Kroah-Hartman , Kay Sievers , Santosh Shilimkar , Daniel Lezcano , Amit Kucheria , Lorenzo Pieralisi , Colin Cross Subject: [PATCHv2 2/5] cpuidle: fix error handling in __cpuidle_register_device Date: Wed, 14 Mar 2012 11:29:51 -0700 Message-Id: <1331749794-8056-3-git-send-email-ccross@android.com> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <1331749794-8056-1-git-send-email-ccross@android.com> References: <1331749794-8056-1-git-send-email-ccross@android.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix the error handling in __cpuidle_register_device to include the missing list_del. Move it to a label, which will simplify the error handling when coupled states are added. Signed-off-by: Colin Cross --- drivers/cpuidle/cpuidle.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) v2: * fix after rename of sys_dev to cpu_dev * reorder error path to reverse of probe path diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 1453830..aacf2f0 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -319,13 +319,18 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) per_cpu(cpuidle_devices, dev->cpu) = dev; list_add(&dev->device_list, &cpuidle_detected_devices); - if ((ret = cpuidle_add_sysfs(cpu_dev))) { - module_put(cpuidle_driver->owner); - return ret; - } + ret = cpuidle_add_sysfs(cpu_dev); + if (ret) + goto err_sysfs; dev->registered = 1; return 0; + +err_sysfs: + list_del(&dev->device_list); + per_cpu(cpuidle_devices, dev->cpu) = NULL; + module_put(cpuidle_driver->owner); + return ret; } /** -- 1.7.9.2