From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752939AbdI1L5N (ORCPT ); Thu, 28 Sep 2017 07:57:13 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7062 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752672AbdI1L5M (ORCPT ); Thu, 28 Sep 2017 07:57:12 -0400 Subject: Re: [PATCH for-next 3/9] RDMA/hns: Add return statement when kzalloc return NULL in hns_roce_v1_recreate_lp_qp To: Leon Romanovsky References: <1506574654-56699-1-git-send-email-xavier.huwei@huawei.com> <1506574654-56699-4-git-send-email-xavier.huwei@huawei.com> <20170928091308.GT2297@mtr-leonro.local> CC: , , , , , , , , , , , From: "Wei Hu (Xavier)" Message-ID: <59CCE38B.4040408@huawei.com> Date: Thu, 28 Sep 2017 19:56:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20170928091308.GT2297@mtr-leonro.local> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.57.115.182] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.59CCE395.019A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 3aba16b8350ad9bb6c63cfd133faa81a Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/9/28 17:13, Leon Romanovsky wrote: > On Thu, Sep 28, 2017 at 12:57:28PM +0800, Wei Hu (Xavier) wrote: >> From: Lijun Ou >> >> When lp_qp_work is NULL, it should be returned ENOMEM. This patch >> mainly fixes it. >> >> Ihis 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: Lijun Ou >> Signed-off-by: Wei Hu (Xavier) >> Signed-off-by: Shaobo Xu >> --- >> drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c >> index 95f5c88..1071fa2 100644 >> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c >> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c >> @@ -912,6 +912,8 @@ static int hns_roce_v1_recreate_lp_qp(struct hns_roce_dev *hr_dev) >> >> lp_qp_work = kzalloc(sizeof(struct hns_roce_recreate_lp_qp_work), >> GFP_KERNEL); >> + if (!lp_qp_work) >> + return -ENOMEM; >> > You will treat this error in the same was as you will treat timeout, > which is wrong. Thanks, Leon We will send v2 to fix the compatible warn info. > 1656 */ > 1657 if (hr_dev->hw->dereg_mr && hns_roce_v1_recreate_lp_qp(hr_dev)) > 1658 dev_warn(&hr_dev->pdev->dev, "recreate lp qp timeout!\n"); > 1659 > 1660 p = (u32 *)(&addr[0]); > > >> INIT_WORK(&(lp_qp_work->work), hns_roce_v1_recreate_lp_qp_work_fn); >> >> -- >> 1.9.1 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html