Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793215922; b=dBeC9JcZ8Wt64MuCiP6auJDt8dj29Z5qA0ephfhdtLU78poEYnUt0/yBOkYv883U64VG zr7biv21yX4IgQiQaD4qIvI6GybabJU9+ZSt4jHW6xNUn+1ujJxuyTJSJJsRxSfu7Wt7J UQUIcuioe2WWF2Vuc2Y50FwFfCgObhUOh1QKH/1ti/0XOdX1iqGRrSBdbZwXKg8ug5pa8 yQhpa9Tsd56sIHgEDv6ZXHiYXi46wOGiGE1OTJbeioKjn7i+ABI44I/C6Zy3DMOo88XBI TCdBsXPAterNH9E2VFP3NYgDYi3H5Akmg44Hq9/OeA/MnOyDdFA+tw0qX2HSvvxREBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793215922; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=9bIyWDuD2XuOVQWBesxhRr/Ji6eGIaaVqaVbzNTvV6Q=; b=i8Y78oYrt0LYWgh9QUA7xZsZNUX1W4yWHD8Ik1B2NNCKzqONSBCALVSMyabHl+BQMyDB Gc2gVYW8knnkJUb5P5D/8/0yOiRdw98i7cNVaJgbIP5IFC1eK24lVTXTmkJXtpmU4uLbm W4fdIHUNECeNHK0SzXUzT9ET5UoyFhA/ytXVeBHwqim2Qtepy31MSASVVLwmsifJGhlI0 pQbW8Tj2YxB4Xbi4tULrp5mS+71kULmdA9tjuZIHRsLvqRepQkREhwLzdlHvT0q59Vyou 2vsvoz7yw5lBoUFyPEfs/NTHK80Nf7EizovDaeU1xPeafUTqBnxWU3pEHBJqzQApI6g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=H3ckofcx; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2712A606A31A; Wed, 28 Oct 2026 19:32:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=H3ckofcx Received: by smtp.kernel.org (Postfix) with ESMTPSA id 747B91F01825; Wed, 28 Oct 2026 19:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793215922; bh=9bIyWDuD2XuOVQWBesxhRr/Ji6eGIaaVqaVbzNTvV6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=H3ckofcxInSNzRmRnzhaSKI9BySrPrLaD8hEt0PKJT7qmGAHYZz7cV7/Uh1uAPcUM gWnAuZpfaqw0hSNRzbYQi+AuIN/LxRmMJFQiGJalDsCfZFtDbXrZFUWo5emoTfUz6e 088h4OSBjYnurl6adRR5FtyI8YxhMazq1OnGoGl0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Abdun Nihaal , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sasha Levin Subject: [PATCH 6.1 1380/1887] platform/x86: int1092: Fix potential memory leak in sar_probe() Date: Wed, 28 Oct 2026 17:57:56 +0100 Message-ID: <20261028170530.850002407@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170459.200466217@linuxfoundation.org> References: <20261028170459.200466217@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Abdun Nihaal [ Upstream commit 30c906cff490c3601ee9ff110fe8115fabe75fd4 ] 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 Link: https://patch.msgid.link/20260723-platx86-v4-1-93b4a178b595@cse.iitm.ac.in Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen Signed-off-by: Sasha Levin --- .../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 8ddfcfbbf3fcc..0a67b26d53a15 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_array(data->total_dev_mode, - sizeof(struct wwan_device_mode_info), GFP_KERNEL); + 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; @@ -254,7 +256,7 @@ static int sar_probe(struct platform_device *device) if (!handle) return -ENODEV; - context = kzalloc(sizeof(*context), GFP_KERNEL); + context = devm_kzalloc(&device->dev, sizeof(*context), GFP_KERNEL); if (!context) return -ENOMEM; @@ -265,7 +267,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++) @@ -273,43 +275,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 int 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); return 0; } -- 2.53.0