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: 8ecac46a60 ("rdma: Add QP resource tracking information")
Signed-off-by: Mark Zhang <markz@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Mark Zhang 2019-09-11 11:12:43 +03:00 committed by Stephen Hemminger
parent 2caa8012e8
commit 4e2d9fc4d8
1 changed files with 3 additions and 0 deletions

View File

@ -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);