]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/ras: Add input pointer validation in ras core helpers
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Thu, 19 Mar 2026 05:30:00 +0000 (11:00 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 23 Mar 2026 18:08:01 +0000 (14:08 -0400)
Add NULL checks for helper input/output pointers that are directly
dereferenced, such as tm, seqno, dev_info and init_config.

Cc: Tao Zhou <tao.zhou1@amd.com>
Cc: YiPeng Chai <YiPeng.Chai@amd.com>
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: YiPeng Chai <YiPeng.Chai@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/ras/rascore/ras_core.c

index d6229f5f9a318d47a2cfe268185e9e8a6c55a779..49b3aa7489ff4366242dbd0806a3280eb7f539d1 100644 (file)
@@ -69,6 +69,9 @@ int ras_core_convert_timestamp_to_time(struct ras_core_context *ras_core,
        int seconds_per_minute = 60;
        int days, remaining_seconds;
 
+       if (!tm)
+               return -EINVAL;
+
        days = div64_u64_rem(timestamp, seconds_per_day, &remainder);
        /* remainder will always be less than seconds_per_day. */
        remaining_seconds = remainder;
@@ -277,6 +280,9 @@ struct ras_core_context *ras_core_create(struct ras_core_config *init_config)
        struct ras_core_context *ras_core;
        struct ras_core_config *config;
 
+       if (!init_config)
+               return NULL;
+
        ras_core = kzalloc_obj(*ras_core);
        if (!ras_core)
                return NULL;
@@ -638,6 +644,9 @@ int ras_core_event_notify(struct ras_core_context *ras_core,
 int ras_core_get_device_system_info(struct ras_core_context *ras_core,
                struct device_system_info *dev_info)
 {
+       if (!dev_info)
+               return -EINVAL;
+
        if (ras_core && ras_core->sys_fn &&
                ras_core->sys_fn->get_device_system_info)
                return ras_core->sys_fn->get_device_system_info(ras_core, dev_info);