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 D10972FA630; Tue, 17 Jun 2025 16:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750179202; cv=none; b=ir4TbFf2Qto2ZlyCdZK7VoswcYg5vBUtwcJ2fa/f48eG4TphM1fWHMdGjaD4u4rRKldSR0eimOjZarbTowRB58+OeRDVzH2yb9XzcAk2RARkCM51RLkLNacKLoBIo5aeuRb/sdggRpu1CSpbxoTtoPtWlwn1+IMApzsFp7hGzgk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750179202; c=relaxed/simple; bh=5s/WtgnJj1IPqs8fWVf1IBPlDfmel6vP8ESDPXqSUFA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lt/ZOzoGM60Jh84pktCgpHlAdQzrcLe1e91yoXv5nFsF7PZTFObtnMrigU5qU+3wwqAWgpI/f681x/iWbiV1nXJvZ9unaVZcEEhWIpNCISv5xLemC6TfNYGtPYL2dhazbiCDn5gDTZlwxXaMeOvb1m06mWdkIT1BPD8iT97r23s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=O1wHJE7w; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="O1wHJE7w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E49EEC4CEE3; Tue, 17 Jun 2025 16:53:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750179202; bh=5s/WtgnJj1IPqs8fWVf1IBPlDfmel6vP8ESDPXqSUFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O1wHJE7w4C7WIeCztTIlhOHXh3EqpDuXH6cyjb76hYgF7O4Ngae5S5YumvsbczaTP fDOrqEt0QqabrTNzWvoDrDS6pvBrGZ+77my7BbUSF7yyx85fHDo/XOepgNV9XcWgGd cjKIFOGCGzK7Lv7ofqFtXC9BZ6PXG3BmtlydP4qY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Laurent Pinchart , Mark Brown , Sasha Levin Subject: [PATCH 6.15 680/780] regulator: max20086: Fix refcount leak in max20086_parse_regulators_dt() Date: Tue, 17 Jun 2025 17:26:28 +0200 Message-ID: <20250617152519.159069481@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250617152451.485330293@linuxfoundation.org> References: <20250617152451.485330293@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit 06118ae36855b7d3d22688298e74a766ccf0cb7a ] There is a missing call to of_node_put() if devm_kcalloc() fails. Fix this by changing the code to use cleanup.h magic to drop the refcount. Fixes: 6b0cd72757c6 ("regulator: max20086: fix invalid memory access") Signed-off-by: Dan Carpenter Link: https://patch.msgid.link/aDVRLqgJWMxYU03G@stanley.mountain Reviewed-by: Laurent Pinchart Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/max20086-regulator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/max20086-regulator.c b/drivers/regulator/max20086-regulator.c index 198d45f8e8849..3d333b61fb18c 100644 --- a/drivers/regulator/max20086-regulator.c +++ b/drivers/regulator/max20086-regulator.c @@ -5,6 +5,7 @@ // Copyright (C) 2022 Laurent Pinchart // Copyright (C) 2018 Avnet, Inc. +#include #include #include #include @@ -133,11 +134,11 @@ static int max20086_regulators_register(struct max20086 *chip) static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on) { struct of_regulator_match *matches; - struct device_node *node; unsigned int i; int ret; - node = of_get_child_by_name(chip->dev->of_node, "regulators"); + struct device_node *node __free(device_node) = + of_get_child_by_name(chip->dev->of_node, "regulators"); if (!node) { dev_err(chip->dev, "regulators node not found\n"); return -ENODEV; @@ -153,7 +154,6 @@ static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on) ret = of_regulator_match(chip->dev, node, matches, chip->info->num_outputs); - of_node_put(node); if (ret < 0) { dev_err(chip->dev, "Failed to match regulators\n"); return -EINVAL; -- 2.39.5