From: Mark Zhang Date: Wed, 11 Sep 2019 08:12:43 +0000 (+0300) Subject: rdma: Check comm string before print in print_comm() X-Git-Tag: v5.3.0~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e2d9fc4d8119fdd536df15cc538002a7d7a0e75;p=thirdparty%2Fiproute2.git rdma: Check comm string before print in print_comm() 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") Signed-off-by: Mark Zhang Signed-off-by: Leon Romanovsky Signed-off-by: Stephen Hemminger --- diff --git a/rdma/res.c b/rdma/res.c index ef863f142..c5e8ba1d7 100644 --- a/rdma/res.c +++ b/rdma/res.c @@ -159,6 +159,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);