From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8B126FA0 for ; Mon, 16 Jan 2023 16:43:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 266FAC433EF; Mon, 16 Jan 2023 16:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673887394; bh=g8ISu+6Q6M2A5mBB4vhainaaLT5aZ4DeAYmj052L+eQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kDTqEUTzc6T+yyYIWtB1LJPyygnlC6Ptog5JXD2aYwVEoZfhIbTtRWVuO4WQOGnrM /l9c9hdMFxP3qcfmduaU0Y2IjN5UgRveSWXbAuTSq1sM9pi+o2UJwTIOO+zRGc3OFQ CiAo2BDL5MY2IlmAMXMYkLo5X5CEdFwFYaZVz7Ww= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yang Yingliang , Mark Brown , Sasha Levin Subject: [PATCH 4.19 131/521] regulator: core: fix module refcount leak in set_supply() Date: Mon, 16 Jan 2023 16:46:33 +0100 Message-Id: <20230116154853.120943679@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154847.246743274@linuxfoundation.org> References: <20230116154847.246743274@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Yang Yingliang [ Upstream commit da46ee19cbd8344d6860816b4827a7ce95764867 ] If create_regulator() fails in set_supply(), the module refcount needs be put to keep refcount balanced. Fixes: e2c09ae7a74d ("regulator: core: Increase refcount for regulator supply's module") Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20221201122706.4055992-2-yangyingliang@huawei.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 07982143ec18..9cf438a37eeb 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1241,6 +1241,7 @@ static int set_supply(struct regulator_dev *rdev, rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY"); if (rdev->supply == NULL) { + module_put(supply_rdev->owner); err = -ENOMEM; return err; } -- 2.35.1