Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6776039ybc; Thu, 28 Nov 2019 05:20:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyYTMQUaV8yRyoWsDu2kgZGgrGnjqeoJhZcMeEl+EzEQYnB/wMdUzdfIL8jS2gA+4qdMBa9 X-Received: by 2002:a17:906:6893:: with SMTP id n19mr170895ejr.238.1574947232720; Thu, 28 Nov 2019 05:20:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574947232; cv=none; d=google.com; s=arc-20160816; b=HtkXVzASdoDkWoT9UECG6wQYFmx33OyRMp9Qidlfc7GfOAcSDqRM/hTXaAdb3I1U0T QhFw00L9GOYswd2dqD+OE/IYGygep9KtoTX3ArXkAGIjdnuz5fOEcM4shIAK+BEB7GlY sj05vKSGW2s0zJ4l4sp7QjfVeoS21YP5gaMdwfD0uDRP1zRggcnBOA8eknWklEUSzmkC 2Gfnf4KzIQMpW0RNMtfn6b7ZUEt6a3ZGjCVGogw6srI4PMS9smifIn/MzUB2guJCdO90 zQSRRDsAYFFbklQ14WYo/RYmFU7khIoE2S28g+PIwG8WB+eCVpTbkbhdlsIcd/llb60o uwKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:subject:cc:to:from :date; bh=7FhV3kMzJN3hZwJnCsgf5axMvgmTRFTn0XG1qnJARpo=; b=XgJQ7YaVeOMkvdQ57cAkF7CBTy8cvIJ72k4kPeQAPUz3I3ihF8XvctzZmBtNt2+BYL z6xh6SxytkO1Ww7kftG0VhZh6wbdyZTEYL7s5zN+DxRKi5S/lE0EOp3fL48lCOm8LrAm nwIzVgkyfXh9qd+u1jRcouxwOaf+jWTsAgz8s4t4+XumEtP68rKbaK4vAMjizh0lxb8l C/ZxOTAfKuO7kPlmVEDebY1bIXg8VZQPYt9/Z3LUFztF3cMwjd00ZMToPLZdxzZQD+Kd VEyqEHxG5f9R8uh/CVs1FmuKi7XDLUWvEKhjPfWyMVjFfJKkvmBZr+ItWLL/oN5rHsLC iZ/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si12582137ejj.367.2019.11.28.05.20.07; Thu, 28 Nov 2019 05:20:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbfK1NSu (ORCPT + 99 others); Thu, 28 Nov 2019 08:18:50 -0500 Received: from foss.arm.com ([217.140.110.172]:35280 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726227AbfK1NSu (ORCPT ); Thu, 28 Nov 2019 08:18:50 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2313312FC; Thu, 28 Nov 2019 05:18:50 -0800 (PST) Received: from localhost (unknown [10.37.6.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 96B123F52E; Thu, 28 Nov 2019 05:18:49 -0800 (PST) Date: Thu, 28 Nov 2019 13:18:48 +0000 From: Mark Brown To: Wen Yang Cc: Liam Girdwood , linux-kernel@vger.kernel.org, Mark Brown Subject: Applied "regulator: fix use after free issue" to the regulator tree In-Reply-To: <20191124145835.25999-1-wenyang@linux.alibaba.com> Message-Id: X-Patchwork-Hint: ignore Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch regulator: fix use after free issue has been applied to the regulator tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-5.5 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 4affd79a125ac91e6a53be843ea3960a8fc00cbb Mon Sep 17 00:00:00 2001 From: Wen Yang Date: Sun, 24 Nov 2019 22:58:35 +0800 Subject: [PATCH] regulator: fix use after free issue This is caused by dereferencing 'rdev' after put_device() in the _regulator_get()/_regulator_put() functions. This patch just moves the put_device() down a bit to avoid the issue. Signed-off-by: Wen Yang Cc: Liam Girdwood Cc: Mark Brown Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20191124145835.25999-1-wenyang@linux.alibaba.com Signed-off-by: Mark Brown --- drivers/regulator/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 5e6c629806e4..c80f3fd9532d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1937,8 +1937,8 @@ struct regulator *_regulator_get(struct device *dev, const char *id, regulator = create_regulator(rdev, dev, id); if (regulator == NULL) { regulator = ERR_PTR(-ENOMEM); - put_device(&rdev->dev); module_put(rdev->owner); + put_device(&rdev->dev); return regulator; } @@ -2059,13 +2059,13 @@ static void _regulator_put(struct regulator *regulator) rdev->open_count--; rdev->exclusive = 0; - put_device(&rdev->dev); regulator_unlock(rdev); kfree_const(regulator->supply_name); kfree(regulator); module_put(rdev->owner); + put_device(&rdev->dev); } /** -- 2.20.1