RDMA/hns: Check return value of kzalloc
authorWei Hu(Xavier) <xavier.huwei@huawei.com>
Fri, 29 Sep 2017 15:10:09 +0000 (23:10 +0800)
committerDoug Ledford <dledford@redhat.com>
Fri, 29 Sep 2017 16:04:45 +0000 (12:04 -0400)
commita74dc41d49959e46ca356a388fab3a23a4b593cd
tree7448cf0db29a1d165a887522ba74ee2c60b44ad9
parentf44c863be282f575becb1aacb69fd42f8ea53c6d
RDMA/hns: Check return value of kzalloc

When lp_qp_work is NULL, we should return ENOMEM.  In order to do so,
we had to make some upper layer functions return a value instead
of being void type so we can propagate the error up the stack.

This patch fixes the smatch error as below:
drivers/infiniband/hw/hns/hns_roce_hw_v1.c:918 hns_roce_v1_recreate_lp_qp()
error: potential null dereference 'lp_qp_work'.  (kzalloc returns null)

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Shaobo Xu <xushaobo2@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hns/hns_roce_device.h
drivers/infiniband/hw/hns/hns_roce_hw_v1.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_main.c