From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752074AbdEAWGK (ORCPT ); Mon, 1 May 2017 18:06:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55646 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751974AbdEAV2D (ORCPT ); Mon, 1 May 2017 17:28:03 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Hunter , Mark Brown , Julia Lawall Subject: [PATCH 4.4 13/43] regulator: core: Clear the supply pointer if enabling fails Date: Mon, 1 May 2017 14:27:13 -0700 Message-Id: <20170501212600.068430884@linuxfoundation.org> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170501212559.546911128@linuxfoundation.org> References: <20170501212559.546911128@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jon Hunter commit 8e5356a73604f53da6a1e0756727cb8f9f7bba17 upstream. During the resolution of a regulator's supply, we may attempt to enable the supply if the regulator itself is already enabled. If enabling the supply fails, then we will call _regulator_put() for the supply. However, the pointer to the supply has not been cleared for the regulator and this will cause a crash if we then unregister the regulator and attempt to call regulator_put() a second time for the supply. Fix this by clearing the supply pointer if enabling the supply after fails when resolving the supply for a regulator. Signed-off-by: Jon Hunter Signed-off-by: Mark Brown Cc: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1519,6 +1519,7 @@ static int regulator_resolve_supply(stru ret = regulator_enable(rdev->supply); if (ret < 0) { _regulator_put(rdev->supply); + rdev->supply = NULL; return ret; } }