Skip to content

Commit 13fe9fa

Browse files
rtauro1895rodrigovivi
authored andcommitted
drm/xe/xe_survivability: Add index bound check
Fix static analysis tool reported issue. Add index bound check before accessing info array to prevent out of bound. Fixes: f4e9fc9 ("drm/xe/xe_survivability: Redesign survivability mode") Signed-off-by: Riana Tauro <riana.tauro@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patch.msgid.link/20251219105224.871930-6-riana.tauro@intel.com Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 3d50c69 commit 13fe9fa

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

drivers/gpu/drm/xe/xe_survivability_mode.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,14 @@ static umode_t survivability_info_attrs_visible(struct kobject *kobj, struct att
251251
struct xe_survivability *survivability = &xe->survivability;
252252
u32 *info = survivability->info;
253253

254-
/* FDO mode is visible only when supported */
255-
if (idx >= MAX_SCRATCH_REG && survivability->version >= 2)
254+
/*
255+
* Last index in survivability_info_attrs is fdo mode and is applicable only in
256+
* version 2 of survivability mode
257+
*/
258+
if (idx == MAX_SCRATCH_REG && survivability->version >= 2)
256259
return 0400;
257-
else if (info[idx])
260+
261+
if (idx < MAX_SCRATCH_REG && info[idx])
258262
return 0400;
259263

260264
return 0;

0 commit comments

Comments
 (0)