Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755501AbaDPKdI (ORCPT ); Wed, 16 Apr 2014 06:33:08 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:51808 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755436AbaDPKdE (ORCPT ); Wed, 16 Apr 2014 06:33:04 -0400 From: Luis Henriques To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Daniel Fu , "Rafael J. Wysocki" , Mark Brown , Luis Henriques Subject: [PATCH 3.11 38/46] cpuidle: Check the result of cpuidle_get_driver() against NULL Date: Wed, 16 Apr 2014 11:31:54 +0100 Message-Id: <1397644322-13905-39-git-send-email-luis.henriques@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1397644322-13905-1-git-send-email-luis.henriques@canonical.com> References: <1397644322-13905-1-git-send-email-luis.henriques@canonical.com> X-Extended-Stable: 3.11 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.11.10.8 -stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Fu commit 3b9c10e98021e1f92e6f8c7ce1778b86ba68db10 upstream. If the current CPU has no cpuidle driver, drv will be NULL in cpuidle_driver_ref(). Check if that is the case before trying to bump up the driver's refcount to prevent the kernel from crashing. [rjw: Subject and changelog] Signed-off-by: Daniel Fu Signed-off-by: Rafael J. Wysocki Cc: Mark Brown Signed-off-by: Luis Henriques --- drivers/cpuidle/driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 3ac499d..6e11701 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c @@ -331,7 +331,8 @@ struct cpuidle_driver *cpuidle_driver_ref(void) spin_lock(&cpuidle_driver_lock); drv = cpuidle_get_driver(); - drv->refcnt++; + if (drv) + drv->refcnt++; spin_unlock(&cpuidle_driver_lock); return drv; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/