* [bug report] IB/hns: Fix the bug when free mr
@ 2017-03-14 13:39 Dan Carpenter
2017-03-15 1:07 ` Shaobo Xu
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2017-03-14 13:39 UTC (permalink / raw)
To: xushaobo2-hv44wF8Li93QT0dZR+AlfA; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
Hello Shaobo Xu,
The patch bfcc681bd09d: "IB/hns: Fix the bug when free mr" from Nov
29, 2016, leads to the following static checker warning:
drivers/infiniband/hw/hns/hns_roce_hw_v1.c:909 hns_roce_v1_recreate_lp_qp()
error: potential null dereference 'lp_qp_work'. (kzalloc returns null)
drivers/infiniband/hw/hns/hns_roce_hw_v1.c
891 static int hns_roce_v1_recreate_lp_qp(struct hns_roce_dev *hr_dev)
892 {
893 struct device *dev = &hr_dev->pdev->dev;
894 struct hns_roce_recreate_lp_qp_work *lp_qp_work;
895 struct hns_roce_free_mr *free_mr;
896 struct hns_roce_v1_priv *priv;
897 struct completion comp;
898 unsigned long end =
899 msecs_to_jiffies(HNS_ROCE_V1_RECREATE_LP_QP_TIMEOUT_MSECS) + jiffies;
900
901 priv = (struct hns_roce_v1_priv *)hr_dev->hw->priv;
902 free_mr = &priv->free_mr;
903
904 lp_qp_work = kzalloc(sizeof(struct hns_roce_recreate_lp_qp_work),
^^^^^^^^^^^^^^^^^^^^
Not checked.
905 GFP_KERNEL);
906
907 INIT_WORK(&(lp_qp_work->work), hns_roce_v1_recreate_lp_qp_work_fn);
908
909 lp_qp_work->ib_dev = &(hr_dev->ib_dev);
910 lp_qp_work->comp = ∁
911 lp_qp_work->comp_flag = 1;
912
913 init_completion(lp_qp_work->comp);
914
915 queue_work(free_mr->free_mr_wq, &(lp_qp_work->work));
916
917 while (time_before_eq(jiffies, end)) {
918 if (try_wait_for_completion(&comp))
919 return 0;
920 msleep(HNS_ROCE_V1_RECREATE_LP_QP_WAIT_VALUE);
921 }
regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] IB/hns: Fix the bug when free mr
2017-03-14 13:39 [bug report] IB/hns: Fix the bug when free mr Dan Carpenter
@ 2017-03-15 1:07 ` Shaobo Xu
0 siblings, 0 replies; 2+ messages in thread
From: Shaobo Xu @ 2017-03-15 1:07 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
hi, Dan:
Thanks for your suggestion.
I will fix the warning later.
Best Regards,
Xu, Shaobo
On 2017/3/14 21:39, Dan Carpenter wrote:
> Hello Shaobo Xu,
>
> The patch bfcc681bd09d: "IB/hns: Fix the bug when free mr" from Nov
> 29, 2016, leads to the following static checker warning:
>
> drivers/infiniband/hw/hns/hns_roce_hw_v1.c:909 hns_roce_v1_recreate_lp_qp()
> error: potential null dereference 'lp_qp_work'. (kzalloc returns null)
>
> drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> 891 static int hns_roce_v1_recreate_lp_qp(struct hns_roce_dev *hr_dev)
> 892 {
> 893 struct device *dev = &hr_dev->pdev->dev;
> 894 struct hns_roce_recreate_lp_qp_work *lp_qp_work;
> 895 struct hns_roce_free_mr *free_mr;
> 896 struct hns_roce_v1_priv *priv;
> 897 struct completion comp;
> 898 unsigned long end =
> 899 msecs_to_jiffies(HNS_ROCE_V1_RECREATE_LP_QP_TIMEOUT_MSECS) + jiffies;
> 900
> 901 priv = (struct hns_roce_v1_priv *)hr_dev->hw->priv;
> 902 free_mr = &priv->free_mr;
> 903
> 904 lp_qp_work = kzalloc(sizeof(struct hns_roce_recreate_lp_qp_work),
> ^^^^^^^^^^^^^^^^^^^^
> Not checked.
>
> 905 GFP_KERNEL);
> 906
> 907 INIT_WORK(&(lp_qp_work->work), hns_roce_v1_recreate_lp_qp_work_fn);
> 908
> 909 lp_qp_work->ib_dev = &(hr_dev->ib_dev);
> 910 lp_qp_work->comp = ∁
> 911 lp_qp_work->comp_flag = 1;
> 912
> 913 init_completion(lp_qp_work->comp);
> 914
> 915 queue_work(free_mr->free_mr_wq, &(lp_qp_work->work));
> 916
> 917 while (time_before_eq(jiffies, end)) {
> 918 if (try_wait_for_completion(&comp))
> 919 return 0;
> 920 msleep(HNS_ROCE_V1_RECREATE_LP_QP_WAIT_VALUE);
> 921 }
>
>
> regards,
> dan carpenter
>
> .
>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-15 1:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-14 13:39 [bug report] IB/hns: Fix the bug when free mr Dan Carpenter
2017-03-15 1:07 ` Shaobo Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox