]> git.ipfire.org Git - thirdparty/iproute2.git/commit
rdma: Fix the error of accessing string variable outside the lifecycle
authorwenglianfa <wenglianfa@huawei.com>
Fri, 29 Dec 2023 06:52:41 +0000 (14:52 +0800)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 8 Jan 2024 16:45:17 +0000 (08:45 -0800)
commit3a882b6b4e0ee8c7cfd11176d36a98d30fc449d3
tree0e05251e280032b1c644ab12365b472792f29a14
parenta903854bad1c5121b35f0f22af18c66a847d20de
rdma: Fix the error of accessing string variable outside the lifecycle

All these SPRINT_BUF(b) definitions are inside the 'if' block, but
accessed outside the 'if' block through the pointers 'comm'. This
leads to empty 'comm' attribute when querying resource information.
So move the definitions to the beginning of the functions to extend
their life cycle.

Before:
$ rdma res show srq
dev hns_0 srqn 0 type BASIC lqpn 18 pdn 5 pid 7775 comm

After:
$ rdma res show srq
dev hns_0 srqn 0 type BASIC lqpn 18 pdn 5 pid 7775 comm ib_send_bw

Fixes: 1808f002dfdd ("lib/fs: fix memory leak in get_task_name()")
Signed-off-by: wenglianfa <wenglianfa@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Acked-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
rdma/res-cmid.c
rdma/res-cq.c
rdma/res-ctx.c
rdma/res-mr.c
rdma/res-pd.c
rdma/res-qp.c
rdma/res-srq.c
rdma/stat.c