mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] platform/x86: int1092: Fix two bugs in SAR driver
@ 2026-07-13 11:02 Abdun Nihaal
  2026-07-13 11:02 ` [PATCH 1/2] platform/x86: int1092: Fix potential memory leak in sar_probe() Abdun Nihaal
  2026-07-13 11:02 ` [PATCH 2/2] platform/x86: int1092: Fix info leak in parse_package() Abdun Nihaal
  0 siblings, 2 replies; 4+ messages in thread
From: Abdun Nihaal @ 2026-07-13 11:02 UTC (permalink / raw)
  To: Shravan Sudhakar, Hans de Goede, Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, stable, Abdun Nihaal, Sashiko

The patchset includes two fixes for
- a potential memory leak in sar_probe()
- an information leak in parse_package()

Both patches are compile tested only.

v2->v3:
- Converted into a patch set with two patches

Link to v1: https://patchwork.kernel.org/project/platform-driver-x86/patch/20260707070524.953741-1-nihaal@cse.iitm.ac.in/
Link to v2: https://patchwork.kernel.org/project/platform-driver-x86/patch/20260710052806.100107-1-nihaal@cse.iitm.ac.in/

Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
---
Abdun Nihaal (2):
      platform/x86: int1092: Fix potential memory leak in sar_probe()
      platform/x86: int1092: Fix info leak in parse_package()

 drivers/platform/x86/intel/int1092/intel_sar.c | 32 ++++++++------------------
 1 file changed, 10 insertions(+), 22 deletions(-)
---
base-commit: bee763d5f341b99cf472afeb508d4988f62a6ca1
change-id: 20260713-platx86-be6e25a3c9dd

Best regards,
-- 
Abdun Nihaal <nihaal@cse.iitm.ac.in>


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

* [PATCH 1/2] platform/x86: int1092: Fix potential memory leak in sar_probe()
  2026-07-13 11:02 [PATCH 0/2] platform/x86: int1092: Fix two bugs in SAR driver Abdun Nihaal
@ 2026-07-13 11:02 ` Abdun Nihaal
  2026-07-13 11:02 ` [PATCH 2/2] platform/x86: int1092: Fix info leak in parse_package() Abdun Nihaal
  1 sibling, 0 replies; 4+ messages in thread
From: Abdun Nihaal @ 2026-07-13 11:02 UTC (permalink / raw)
  To: Shravan Sudhakar, Hans de Goede, Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, stable, Abdun Nihaal

The memory allocated for device_mode_info in parse_package() called by
sar_get_data() is not freed in some of the error paths in sar_probe().
Fix that by converting to use device managed allocations.

Fixes: dcfbd31ef4bc ("platform/x86: BIOS SAR driver for Intel M.2 Modem")
Cc: stable@vger.kernel.org
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
---
Compile tested only. Issue found using static analysis.

v1->v2:
- Changed the patch to instead use device managed allocations for both
  the device_mode_info and the context structure, as suggested by Ilpo
  Järvinen.
v2->v3:
- Align the arguments to the opening paranthesis as suggested by Ilpo
  Järvinen.

Link to v1: https://patchwork.kernel.org/project/platform-driver-x86/patch/20260707070524.953741-1-nihaal@cse.iitm.ac.in/
Link to v2: https://patchwork.kernel.org/project/platform-driver-x86/patch/20260710052806.100107-1-nihaal@cse.iitm.ac.in/
---
 drivers/platform/x86/intel/int1092/intel_sar.c | 32 ++++++++------------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/platform/x86/intel/int1092/intel_sar.c b/drivers/platform/x86/intel/int1092/intel_sar.c
index 849f7b415c1e..7263114f0b3d 100644
--- a/drivers/platform/x86/intel/int1092/intel_sar.c
+++ b/drivers/platform/x86/intel/int1092/intel_sar.c
@@ -91,8 +91,10 @@ static acpi_status parse_package(struct wwan_sar_context *context, union acpi_ob
 	    item->package.count <= data->total_dev_mode)
 		return AE_ERROR;
 
-	data->device_mode_info = kmalloc_objs(struct wwan_device_mode_info,
-					      data->total_dev_mode);
+	data->device_mode_info = devm_kmalloc_array(&context->sar_device->dev,
+						    data->total_dev_mode,
+						    sizeof(*data->device_mode_info),
+						    GFP_KERNEL);
 	if (!data->device_mode_info)
 		return AE_ERROR;
 
@@ -253,7 +255,7 @@ static int sar_probe(struct platform_device *device)
 	if (!handle)
 		return -ENODEV;
 
-	context = kzalloc_obj(*context);
+	context = devm_kzalloc(&device->dev, sizeof(*context), GFP_KERNEL);
 	if (!context)
 		return -ENOMEM;
 
@@ -264,7 +266,7 @@ static int sar_probe(struct platform_device *device)
 	result = guid_parse(SAR_DSM_UUID, &context->guid);
 	if (result) {
 		dev_err(&device->dev, "SAR UUID parse error: %d\n", result);
-		goto r_free;
+		return result;
 	}
 
 	for (reg = 0; reg < MAX_REGULATORY; reg++)
@@ -272,43 +274,29 @@ static int sar_probe(struct platform_device *device)
 
 	if (sar_get_device_mode(device) != AE_OK) {
 		dev_err(&device->dev, "Failed to get device mode\n");
-		result = -EIO;
-		goto r_free;
+		return -EIO;
 	}
 
 	result = sysfs_create_group(&device->dev.kobj, &intcsar_group);
 	if (result) {
 		dev_err(&device->dev, "sysfs creation failed\n");
-		goto r_free;
+		return result;
 	}
 
 	if (acpi_install_notify_handler(ACPI_HANDLE(&device->dev), ACPI_DEVICE_NOTIFY,
 					sar_notify, (void *)device) != AE_OK) {
 		dev_err(&device->dev, "Failed acpi_install_notify_handler\n");
-		result = -EIO;
-		goto r_sys;
+		sysfs_remove_group(&device->dev.kobj, &intcsar_group);
+		return -EIO;
 	}
 	return 0;
-
-r_sys:
-	sysfs_remove_group(&device->dev.kobj, &intcsar_group);
-r_free:
-	kfree(context);
-	return result;
 }
 
 static void sar_remove(struct platform_device *device)
 {
-	struct wwan_sar_context *context = dev_get_drvdata(&device->dev);
-	int reg;
-
 	acpi_remove_notify_handler(ACPI_HANDLE(&device->dev),
 				   ACPI_DEVICE_NOTIFY, sar_notify);
 	sysfs_remove_group(&device->dev.kobj, &intcsar_group);
-	for (reg = 0; reg < MAX_REGULATORY; reg++)
-		kfree(context->config_data[reg].device_mode_info);
-
-	kfree(context);
 }
 
 static struct platform_driver sar_driver = {

-- 
2.43.0


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

* [PATCH 2/2] platform/x86: int1092: Fix info leak in parse_package()
  2026-07-13 11:02 [PATCH 0/2] platform/x86: int1092: Fix two bugs in SAR driver Abdun Nihaal
  2026-07-13 11:02 ` [PATCH 1/2] platform/x86: int1092: Fix potential memory leak in sar_probe() Abdun Nihaal
@ 2026-07-13 11:02 ` Abdun Nihaal
  2026-07-21 16:32   ` Ilpo Järvinen
  1 sibling, 1 reply; 4+ messages in thread
From: Abdun Nihaal @ 2026-07-13 11:02 UTC (permalink / raw)
  To: Shravan Sudhakar, Hans de Goede, Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, stable, Abdun Nihaal, Sashiko

Sashiko reports a possible information leak due to a non-zeroized
memory allocation for device_mode_info. Fix that by switching to use
devm_kcalloc() for allocation.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260710052806.100107-1-nihaal%40cse.iitm.ac.in
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
---
Newly added in v3
---
 drivers/platform/x86/intel/int1092/intel_sar.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/intel/int1092/intel_sar.c b/drivers/platform/x86/intel/int1092/intel_sar.c
index 7263114f0b3d..f506155f35d4 100644
--- a/drivers/platform/x86/intel/int1092/intel_sar.c
+++ b/drivers/platform/x86/intel/int1092/intel_sar.c
@@ -91,10 +91,10 @@ static acpi_status parse_package(struct wwan_sar_context *context, union acpi_ob
 	    item->package.count <= data->total_dev_mode)
 		return AE_ERROR;
 
-	data->device_mode_info = devm_kmalloc_array(&context->sar_device->dev,
-						    data->total_dev_mode,
-						    sizeof(*data->device_mode_info),
-						    GFP_KERNEL);
+	data->device_mode_info = devm_kcalloc(&context->sar_device->dev,
+					      data->total_dev_mode,
+					      sizeof(*data->device_mode_info),
+					      GFP_KERNEL);
 	if (!data->device_mode_info)
 		return AE_ERROR;
 

-- 
2.43.0


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

* Re: [PATCH 2/2] platform/x86: int1092: Fix info leak in parse_package()
  2026-07-13 11:02 ` [PATCH 2/2] platform/x86: int1092: Fix info leak in parse_package() Abdun Nihaal
@ 2026-07-21 16:32   ` Ilpo Järvinen
  0 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2026-07-21 16:32 UTC (permalink / raw)
  To: Abdun Nihaal
  Cc: Shravan Sudhakar, Hans de Goede, platform-driver-x86, LKML,
	stable, Sashiko

On Mon, 13 Jul 2026, Abdun Nihaal wrote:

> Sashiko reports a possible information leak due to a non-zeroized
> memory allocation for device_mode_info. Fix that by switching to use
> devm_kcalloc() for allocation.

Hi,

Please also explain here through which path the information is leaked to 
permanently record it into commit itself.

You can mostly base it on Sashiko's findings but please avoid making it 
too verbose (AI tends to be overly verbose about trivialities).

> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260710052806.100107-1-nihaal%40cse.iitm.ac.in
> Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>

--
 i.


> ---
> Newly added in v3
> ---
>  drivers/platform/x86/intel/int1092/intel_sar.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/int1092/intel_sar.c b/drivers/platform/x86/intel/int1092/intel_sar.c
> index 7263114f0b3d..f506155f35d4 100644
> --- a/drivers/platform/x86/intel/int1092/intel_sar.c
> +++ b/drivers/platform/x86/intel/int1092/intel_sar.c
> @@ -91,10 +91,10 @@ static acpi_status parse_package(struct wwan_sar_context *context, union acpi_ob
>  	    item->package.count <= data->total_dev_mode)
>  		return AE_ERROR;
>  
> -	data->device_mode_info = devm_kmalloc_array(&context->sar_device->dev,
> -						    data->total_dev_mode,
> -						    sizeof(*data->device_mode_info),
> -						    GFP_KERNEL);
> +	data->device_mode_info = devm_kcalloc(&context->sar_device->dev,
> +					      data->total_dev_mode,
> +					      sizeof(*data->device_mode_info),
> +					      GFP_KERNEL);
>  	if (!data->device_mode_info)
>  		return AE_ERROR;
>  
> 
> 


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

end of thread, other threads:[~2026-07-21 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-13 11:02 [PATCH 0/2] platform/x86: int1092: Fix two bugs in SAR driver Abdun Nihaal
2026-07-13 11:02 ` [PATCH 1/2] platform/x86: int1092: Fix potential memory leak in sar_probe() Abdun Nihaal
2026-07-13 11:02 ` [PATCH 2/2] platform/x86: int1092: Fix info leak in parse_package() Abdun Nihaal
2026-07-21 16:32   ` Ilpo Järvinen

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®