Skip to content

Commit c2803bd

Browse files
benhor01ctmarinas
authored andcommitted
arm_mpam: Stop using uninitialized variables in __ris_msmon_read()
Dan has reported two uses of uninitialized variables in __ris_msmon_read(). If an unknown monitor type is encountered then the local variable, now, is used uninitialized. Fix this by returning early on error. If a non-mbwu monitor is being read then the local variable, overflow, is not initialized but still read. Initialize it to false as overflow is not relevant for csu monitors. Fixes: 823e7c3 ("arm_mpam: Add mpam_msmon_read() to read monitor value") Fixes: 9e5afb7 ("arm_mpam: Use long MBWU counters if supported") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202512091519.RBwiJcSq-lkp@intel.com/ Closes: https://lore.kernel.org/r/202512100547.N7QPYgfb-lkp@intel.com/ Signed-off-by: Ben Horgan <ben.horgan@arm.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent dd4d71f commit c2803bd

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/resctrl/mpam_devices.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static void __ris_msmon_read(void *arg)
10721072
u64 now;
10731073
bool nrdy = false;
10741074
bool config_mismatch;
1075-
bool overflow;
1075+
bool overflow = false;
10761076
struct mon_read *m = arg;
10771077
struct mon_cfg *ctx = m->ctx;
10781078
bool reset_on_next_read = false;
@@ -1176,10 +1176,11 @@ static void __ris_msmon_read(void *arg)
11761176
}
11771177
mpam_mon_sel_unlock(msc);
11781178

1179-
if (nrdy) {
1179+
if (nrdy)
11801180
m->err = -EBUSY;
1181+
1182+
if (m->err)
11811183
return;
1182-
}
11831184

11841185
*m->val += now;
11851186
}

0 commit comments

Comments
 (0)