Linux CXL
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>,
	"Weiny, Ira" <ira.weiny@intel.com>
Cc: "Williams, Dan J" <dan.j.williams@intel.com>,
	"Jiang, Dave" <dave.jiang@intel.com>,
	"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>
Subject: Re: [PATCH ndctl 2/3] cxl/monitor: retain error code in monitor_event()
Date: Wed, 22 Feb 2023 06:33:49 +0000	[thread overview]
Message-ID: <6b68c9f360ede90ebd724771fc938820a12e274b.camel@intel.com> (raw)
In-Reply-To: <63f57652656e8_1dd2fc294b@iweiny-mobl.notmuch>

On Tue, 2023-02-21 at 17:56 -0800, Ira Weiny wrote:
> 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 <dave.jiang@intel.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> > ---
> >  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");
> 
> Is this even worth printing?  Perhaps just make
> cxl_event_tracing_disable() return void?

I thought about it, but the underlying tracefs_trace_off() returns an
int, which is probably why cxl_event_tracing_disable() does too. Having
the print satisfies static analyzers that we're checking the return
value - other than that I agree it doesn't add much.

> 
> Either way:
> 
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>

Thanks Ira!

> 
> >  event_en_err:
> >  epoll_ctl_err:
> >         close(fd);
> > 
> > -- 
> > 2.39.1
> > 
> > 
> 
> 


  reply	other threads:[~2023-02-22  6:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-18  0:40 [PATCH ndctl 0/3] cxl/monitor: coverity and misc other fixes Vishal Verma
2023-02-18  0:40 ` [PATCH ndctl 1/3] cxl/event_trace: fix a resource leak in cxl_event_to_json() Vishal Verma
2023-02-21 16:44   ` Dave Jiang
2023-02-22  1:53   ` Ira Weiny
2023-02-18  0:40 ` [PATCH ndctl 2/3] cxl/monitor: retain error code in monitor_event() Vishal Verma
2023-02-21 16:45   ` Dave Jiang
2023-02-22  1:56   ` Ira Weiny
2023-02-22  6:33     ` Verma, Vishal L [this message]
2023-02-18  0:40 ` [PATCH ndctl 3/3] test/cxl-security.sh: avoid intermittent failures due to sasync probe Vishal Verma
2023-02-21 16:45   ` Dave Jiang
2023-02-21 17:22   ` Alison Schofield
2023-02-21 18:08     ` Dan Williams
2023-02-21 18:13     ` Verma, Vishal L
2023-02-21 18:34       ` Alison Schofield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6b68c9f360ede90ebd724771fc938820a12e274b.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox