On 2/17/23 5:40 PM, Vishal Verma wrote:
Static analysis reports that the error unwinding path in monitor_event()
overwrites 'rc' with the return from cxl_event_tracing_disable(). This
masks the actual error code from either epoll_wait() or
cxl_parse_events() which is the one that should be propagated.
Print a spot error in case there's an error while disabling tracing, but
otherwise retain the rc from the main body of the function.
Fixes: 299f69f974a6 ("cxl/monitor: add a new monitor command for CXL trace
events")
Cc: Dave Jiang <[email protected]>
Cc: Dan Williams <[email protected]>
Signed-off-by: Vishal Verma <[email protected]>
Reviewed-by: Dave Jiang <[email protected]>
---
cxl/monitor.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/cxl/monitor.c b/cxl/monitor.c
index 31e6f98..749f472 100644
--- a/cxl/monitor.c
+++ b/cxl/monitor.c
@@ -130,7 +130,8 @@ static int monitor_event(struct cxl_ctx *ctx)
}
parse_err:
- rc = cxl_event_tracing_disable(inst);
+ if (cxl_event_tracing_disable(inst) < 0)
+ err(&monitor, "failed to disable tracing\n");
event_en_err:
epoll_ctl_err:
close(fd);