mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.1 01/12] soc: qcom: Add check devm_kasprintf() returned value
@ 2024-11-12 10:37 Sasha Levin
  2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 02/12] regulator: rk808: Add apply_bit for BUCK3 on RK809 Sasha Levin
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Sasha Levin @ 2024-11-12 10:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Charles Han, Bjorn Andersson, Sasha Levin, konradybcio, linux-arm-msm

From: Charles Han <hanchunchao@inspur.com>

[ Upstream commit e694d2b5c58ba2d1e995d068707c8d966e7f5f2a ]

devm_kasprintf() can return a NULL pointer on failure but this
returned value in qcom_socinfo_probe() is not checked.

Signed-off-by: Charles Han <hanchunchao@inspur.com>
Link: https://lore.kernel.org/r/20240929072349.202520-1-hanchunchao@inspur.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/soc/qcom/socinfo.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index aa37e1bad095c..66219ccd8d47f 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -649,10 +649,16 @@ static int qcom_socinfo_probe(struct platform_device *pdev)
 	qs->attr.revision = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%u.%u",
 					   SOCINFO_MAJOR(le32_to_cpu(info->ver)),
 					   SOCINFO_MINOR(le32_to_cpu(info->ver)));
-	if (offsetof(struct socinfo, serial_num) <= item_size)
+	if (!qs->attr.soc_id || qs->attr.revision)
+		return -ENOMEM;
+
+	if (offsetof(struct socinfo, serial_num) <= item_size) {
 		qs->attr.serial_number = devm_kasprintf(&pdev->dev, GFP_KERNEL,
 							"%u",
 							le32_to_cpu(info->serial_num));
+		if (!qs->attr.serial_number)
+			return -ENOMEM;
+	}
 
 	qs->soc_dev = soc_device_register(&qs->attr);
 	if (IS_ERR(qs->soc_dev))
-- 
2.43.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-11-12 10:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-12 10:37 [PATCH AUTOSEL 6.1 01/12] soc: qcom: Add check devm_kasprintf() returned value Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 02/12] regulator: rk808: Add apply_bit for BUCK3 on RK809 Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 03/12] platform/x86: dell-smbios-base: Extends support to Alienware products Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 04/12] platform/x86: dell-wmi-base: Handle META key Lock/Unlock events Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 05/12] tools/lib/thermal: Remove the thermal.h soft link when doing make clean Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 06/12] can: j1939: fix error in J1939 documentation Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 07/12] platform/x86: thinkpad_acpi: Fix for ThinkPad's with ECFW showing incorrect fan speed Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 08/12] ASoC: amd: yc: Support dmic on another model of Lenovo Thinkpad E14 Gen 6 Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 09/12] ASoC: stm: Prevent potential division by zero in stm32_sai_mclk_round_rate() Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 10/12] ASoC: stm: Prevent potential division by zero in stm32_sai_get_clk_div() Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 11/12] drm: panel-orientation-quirks: Make Lenovo Yoga Tab 3 X90F DMI match less strict Sasha Levin
2024-11-12 10:37 ` [PATCH AUTOSEL 6.1 12/12] proc/softirqs: replace seq_printf with seq_put_decimal_ull_width Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®