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 1FA7F78281; Wed, 7 Aug 2024 15:08:51 +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=1723043331; cv=none; b=I3ektRjADEl3xemKG+BNsfaTUVzFGJoiCGpZXx4fIo1LGF8xuK0+CJfx8ns+menWHK8zMNk+roejaGIqOeOTILSrM0ELetKA1zzuOseA2hcLA0suxLalIP6Hvi+wdrhXmwvmTak092uEjna5T/VlB6JKG5+PPOqIMSTvSHl7OqY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723043331; c=relaxed/simple; bh=fx6WkcMo/U2au1sH22oEYdWfWR/JxsbSY5qT+aFwE9Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YdPd7vXRdY5MV1El5Ya2L35UQSNKzEFMr0+2dsQFN6DdWMhyDz69hqOsXJU/Hc63PBnp8sbBhshqKNcPwEwFQGdh+rwAPLea/WkBXxheiogp6QBP7Bi6Hf+0GqTGCaAXW+vPD/okPbdLy/2sOdhRW0NlU4syEiEMr1a6yT7h45Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=n/1f14oo; 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="n/1f14oo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A523CC32781; Wed, 7 Aug 2024 15:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723043331; bh=fx6WkcMo/U2au1sH22oEYdWfWR/JxsbSY5qT+aFwE9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n/1f14oofoOns+U4L4RMEsMSDCwB6vmJ3z7lYhnNuS64VQyi8beoPpJRNmEdWxLYr nENhZCytvGnXDaj7CZz0dEdJNbhc0wmQVJocSwG4cqxi42CXdSTQfvzeqU8HyyAEJv TCKX1jjsM9S/XxRVLYNX0MY/857iWMDwGCVdpvhY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Javier Carrasco , Viresh Kumar , Sasha Levin Subject: [PATCH 6.6 022/121] cpufreq: qcom-nvmem: fix memory leaks in probe error paths Date: Wed, 7 Aug 2024 16:59:14 +0200 Message-ID: <20240807150020.080637151@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240807150019.412911622@linuxfoundation.org> References: <20240807150019.412911622@linuxfoundation.org> User-Agent: quilt/0.67 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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Javier Carrasco [ Upstream commit d01c84b97f19f1137211e90b0a910289a560019e ] The code refactoring added new error paths between the np device node allocation and the call to of_node_put(), which leads to memory leaks if any of those errors occur. Add the missing of_node_put() in the error paths that require it. Cc: stable@vger.kernel.org Fixes: 57f2f8b4aa0c ("cpufreq: qcom: Refactor the driver to make it easier to extend") Signed-off-by: Javier Carrasco Signed-off-by: Viresh Kumar Signed-off-by: Sasha Levin --- drivers/cpufreq/qcom-cpufreq-nvmem.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c index 03586fee15aac..ef51dfb39baa9 100644 --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c @@ -249,23 +249,30 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) drv = devm_kzalloc(&pdev->dev, struct_size(drv, cpus, num_possible_cpus()), GFP_KERNEL); - if (!drv) + if (!drv) { + of_node_put(np); return -ENOMEM; + } match = pdev->dev.platform_data; drv->data = match->data; - if (!drv->data) + if (!drv->data) { + of_node_put(np); return -ENODEV; + } if (drv->data->get_version) { speedbin_nvmem = of_nvmem_cell_get(np, NULL); - if (IS_ERR(speedbin_nvmem)) + if (IS_ERR(speedbin_nvmem)) { + of_node_put(np); return dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem), "Could not get nvmem cell\n"); + } ret = drv->data->get_version(cpu_dev, speedbin_nvmem, &pvs_name, drv); if (ret) { + of_node_put(np); nvmem_cell_put(speedbin_nvmem); return ret; } -- 2.43.0