mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
x86/pmem: Check for platform_device_alloc() retval
Add proper error handling for the case when platform_device_alloc() returns NULL due to memory allocation failure. This prevents a potential NULL pointer dereference when trying to use the pdev pointer without checking if allocation succeeded. [ bp: Massage commit message. ] Signed-off-by: Li Jun <lijun01@kylinos.cn> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://patch.msgid.link/20260602100711.2542568-1-lijun01@kylinos.cn
This commit is contained in:
committed by
Borislav Petkov (AMD)
parent
d022ff2557
commit
17b22e7a38
@@ -27,6 +27,8 @@ static __init int register_e820_pmem(void)
|
||||
* simply here to trigger the module to load on demand.
|
||||
*/
|
||||
pdev = platform_device_alloc("e820_pmem", -1);
|
||||
if (!pdev)
|
||||
return -ENOMEM;
|
||||
|
||||
rc = platform_device_add(pdev);
|
||||
if (rc)
|
||||
|
||||
Reference in New Issue
Block a user