Skip to contentSkip to conversation

arm_mpam: resctrl: mpam resctrl glue code fixes

PATCH In review Ben Horgan 2 participants 7 messages Apr 14 MPAM driver

lore
Share & tools
lore

Ben Horgan

author maintainer
#0 lore raw

cover arm_mpam: resctrl: mpam resctrl glue code fixes

A couple of minor fixes for the new mpam resctrl glue code. These fix a sparse warning and and use of an unitialized variable in an unexpected error case.

Thanks for the bug reports.

Based on arm64 for-next/mpam.
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/mpam

Ben Horgan (2):
arm_mpam: resctrl: Fix the check for no monitor components found
arm_mpam: resctrl: Make resctrl_mon_ctx_waiters static

 drivers/resctrl/mpam_resctrl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH 1/2 arm_mpam: resctrl: Fix broken error path in mpam_resctrl_alloc_domain()

Dan Carpenter reports that, in mpam_resctrl_alloc_domain(), any_mon_comp is used in an 'if' condition when it may be uninitialized. Initialize it to NULL so that the check behaves correctly when no monitor components are found.

Fixes 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")
---
 drivers/resctrl/mpam_resctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/resctrl/mpam_resctrl.c +1 -1
index a9938006d0e6..d80df486a313 100644
@@ -1399,7 +1399,7 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
 	}
 
 	if (r->mon_capable) {
-		struct mpam_component *any_mon_comp;
+		struct mpam_component *any_mon_comp = NULL;
 		struct mpam_resctrl_mon *mon;
 		enum resctrl_event_id eventid;
 
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

Re: [PATCH v1 1/2] arm_mpam: resctrl: Fix broken error path in mpam_resctrl_alloc_domain()

Apologies, I just sent the same patch twice with different subjects. This one can be ignored.

Thanks,

Ben

Quoted 25 lines · Ben Horgan

Dan Carpenter reports that, in mpam_resctrl_alloc_domain(), any_mon_comp is used in an 'if' condition when it may be uninitialized. Initialize it to NULL so that the check behaves correctly when no monitor components are found.

Fixes 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")
---
 drivers/resctrl/mpam_resctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/resctrl/mpam_resctrl.c +1 -1
index a9938006d0e6..d80df486a313 100644
@@ -1399,7 +1399,7 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
 	}
 
 	if (r->mon_capable) {
-		struct mpam_component *any_mon_comp;
+		struct mpam_component *any_mon_comp = NULL;
 		struct mpam_resctrl_mon *mon;
 		enum resctrl_event_id eventid;
 
author maintainer
#3 lore raw

PATCH 1/2 arm_mpam: resctrl: Fix the check for no monitor components found

In reply to Ben Horgan

Dan Carpenter reports that, in mpam_resctrl_alloc_domain(), any_mon_comp is used in an 'if' condition when it may be uninitialized. Initialize it to NULL so that the check behaves correctly when no monitor components are found.

Fixes 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")
---
 drivers/resctrl/mpam_resctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/resctrl/mpam_resctrl.c +1 -1
index a9938006d0e6..d80df486a313 100644
@@ -1399,7 +1399,7 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
 	}
 
 	if (r->mon_capable) {
-		struct mpam_component *any_mon_comp;
+		struct mpam_component *any_mon_comp = NULL;
 		struct mpam_resctrl_mon *mon;
 		enum resctrl_event_id eventid;
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/2
#4 lore raw

Re: [PATCH v1 1/2] arm_mpam: resctrl: Fix the check for no monitor components found

Quoted 5 lines · Ben Horgan

Dan Carpenter reports that, in mpam_resctrl_alloc_domain(), any_mon_comp is used in an 'if' condition when it may be uninitialized. Initialize it to NULL so that the check behaves correctly when no monitor components are found.

Quoted 7 lines
Fixes 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")
---
  drivers/resctrl/mpam_resctrl.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
author maintainer
#5 lore raw

PATCH 2/2 arm_mpam: resctrl: Make resctrl_mon_ctx_waiters static

In reply to Ben Horgan

resctrl_mon_ctx_waiters is not used outside of this file, so make it static. This fixes the sparse warning:

drivers/resctrl/mpam_resctrl.c:25:1: warning: symbol 'resctrl_mon_ctx_waiters' was not declared. Should it be static?

Fixes 2a3c79c61539 ("arm_mpam: resctrl: Allow resctrl to allocate monitors")
---
 drivers/resctrl/mpam_resctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/resctrl/mpam_resctrl.c +1 -1
index d80df486a313..bb933b224851 100644
@@ -22,7 +22,7 @@
 
 #include "mpam_internal.h"
 
-DECLARE_WAIT_QUEUE_HEAD(resctrl_mon_ctx_waiters);
+static DECLARE_WAIT_QUEUE_HEAD(resctrl_mon_ctx_waiters);
 
 /*
  * The classes we've picked to map to resctrl resources, wrapped
Signature · 1 line
2.43.0
Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH v1 2/2] arm_mpam: resctrl: Make resctrl_mon_ctx_waiters static

Quoted 5 lines · Ben Horgan

resctrl_mon_ctx_waiters is not used outside of this file, so make it static. This fixes the sparse warning:

drivers/resctrl/mpam_resctrl.c:25:1: warning: symbol 'resctrl_mon_ctx_waiters' was not declared. Should it be static?

Quoted 8 lines
Fixes 2a3c79c61539 ("arm_mpam: resctrl: Allow resctrl to allocate monitors")
---
  drivers/resctrl/mpam_resctrl.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)