]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
extcon: realtek: fix NULL deref check in extcon_rtk_type_c_probe
authorCharles Han <hanchunchao@inspur.com>
Fri, 25 Oct 2024 09:46:50 +0000 (17:46 +0800)
committerChanwoo Choi <cw00.choi@samsung.com>
Sun, 8 Dec 2024 12:59:39 +0000 (21:59 +0900)
In extcon_rtk_type_c_probe() devm_kzalloc() may return NULL but this
returned value is not checked.

Fixes: 8a590d7371f0 ("extcon: add Realtek DHC RTD SoC Type-C driver")
Link: https://lore.kernel.org/lkml/20241025094650.253599-1-hanchunchao@inspur.com/
Signed-off-by: Charles Han <hanchunchao@inspur.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
drivers/extcon/extcon-rtk-type-c.c

index 19a01e66373304b2bb9ccd655201797b8278b67d..2820c7e8248184e90a4ab69425c49e55ce165b71 100644 (file)
@@ -1369,6 +1369,8 @@ static int extcon_rtk_type_c_probe(struct platform_device *pdev)
        }
 
        type_c->type_c_cfg = devm_kzalloc(dev, sizeof(*type_c_cfg), GFP_KERNEL);
+       if (!type_c->type_c_cfg)
+               return -ENOMEM;
 
        memcpy(type_c->type_c_cfg, type_c_cfg, sizeof(*type_c_cfg));