ACPI: APD: Check for NULL pointer after calling devm_ioremap()
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Fri, 7 Jan 2022 03:35:16 +0000 (11:35 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 11 Jan 2022 15:35:41 +0000 (16:35 +0100)
Because devres_alloc() may fail, devm_ioremap() may return NULL.

Then, 'clk_data->base' will be assigned to clkdev->data->base in
platform_device_register_data().

The PTR_ERR_OR_ZERO() check on clk_data does not cover 'base', so
it is better to add an explicit check against NULL after updating
it.

Fixes: 3f4ba94e3615 ("ACPI: APD: Add AMD misc clock handler support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
[ rjw: Changelog rewrite ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/acpi_apd.c

index 6e02448d15d951967de0972843770529e6bc3852..9db6409ecb470fb708898280f1f820d1814cdd4f 100644 (file)
@@ -95,6 +95,8 @@ static int fch_misc_setup(struct apd_private_data *pdata)
                                              resource_size(rentry->res));
                break;
        }
+       if (!clk_data->base)
+               return -ENOMEM;
 
        acpi_dev_free_resource_list(&resource_list);