Message ID | 20190911081243.28917-1-leon@kernel.org |
---|---|
State | Accepted |
Delegated to: | stephen hemminger |
Headers | show |
Series | [iproute2-next] rdma: Check comm string before print in print_comm() | expand |
On 9/11/19 2:12 AM, Leon Romanovsky wrote: > From: Mark Zhang <markz@mellanox.com> > > Broken kernels (not-upstream) can provide wrong empty "comm" field. > It causes to segfault while printing in JSON format. > > Fixes: 8ecac46a60ff ("rdma: Add QP resource tracking information") that commit is from 2018, so this should go to master; re-assigned in patchwork. > Signed-off-by: Mark Zhang <markz@mellanox.com> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com> > --- > rdma/res.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/rdma/res.c b/rdma/res.c > index 97a7b964..6003006e 100644 > --- a/rdma/res.c > +++ b/rdma/res.c > @@ -161,6 +161,9 @@ void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line) > { > char tmp[18]; > > + if (!str) > + return; > + > if (rd->json_output) { > /* Don't beatify output in JSON format */ > jsonw_string_field(rd->jw, "comm", str); >
On Sun, Sep 15, 2019 at 11:47:19AM -0600, David Ahern wrote: > On 9/11/19 2:12 AM, Leon Romanovsky wrote: > > From: Mark Zhang <markz@mellanox.com> > > > > Broken kernels (not-upstream) can provide wrong empty "comm" field. > > It causes to segfault while printing in JSON format. > > > > Fixes: 8ecac46a60ff ("rdma: Add QP resource tracking information") > > that commit is from 2018, so this should go to master; re-assigned in > patchwork. This is exactly why I sent it to -next, it is not urgent :) Thanks
diff --git a/rdma/res.c b/rdma/res.c index 97a7b964..6003006e 100644 --- a/rdma/res.c +++ b/rdma/res.c @@ -161,6 +161,9 @@ void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line) { char tmp[18]; + if (!str) + return; + if (rd->json_output) { /* Don't beatify output in JSON format */ jsonw_string_field(rd->jw, "comm", str);