public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
Cc: dledford@redhat.com, linux-rdma@vger.kernel.org,
	lijun_nudt@163.com, oulijun@huawei.com,
	charles.chenxin@huawei.com, liuyixian@huawei.com,
	xushaobo2@huawei.com, zhangxiping3@huawei.com,
	xavier.huwei@tom.com, linuxarm@huawei.com,
	linux-kernel@vger.kernel.org, shaobohsu@163.com
Subject: Re: [PATCH for-next 3/9] RDMA/hns: Add return statement when kzalloc return NULL in hns_roce_v1_recreate_lp_qp
Date: Thu, 28 Sep 2017 15:59:12 +0300	[thread overview]
Message-ID: <20170928125912.GU2297@mtr-leonro.local> (raw)
In-Reply-To: <59CCE38B.4040408@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 2611 bytes --]

On Thu, Sep 28, 2017 at 07:56:59PM +0800, Wei Hu (Xavier) wrote:
>
>
> 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 <oulijun@huawei.com>
> > >
> > > 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 <oulijun@huawei.com>
> > > Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> > > Signed-off-by: Shaobo Xu <xushaobo2@huawei.com>
> > > ---
> > >   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.

No, you missed the point.
From the code flow below the behavior of hns_roce_v1_recreate_lp_qp
for ENOMEM and ETIMEOUT returns will be the same and it is wrong.

For the ETIMEOUT, you can continue, for ENOMEM, you should properly
unfold the whole flow.

Thanks


> > 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
>
>
> --
> 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-09-28 12:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28  4:57 [PATCH for-next 0/9] Bug fixes & Code improvements in hip06 and hip08 RoCE driver Wei Hu (Xavier)
2017-09-28  4:57 ` [PATCH for-next 1/9] RDMA/hns: Modify the value with rd&dest_rd of qp_attr Wei Hu (Xavier)
2017-09-28  4:57 ` [PATCH for-next 2/9] RDMA/hns: Factor out the code for checking sdb status into a new function Wei Hu (Xavier)
     [not found]   ` <1506574654-56699-3-git-send-email-xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-09-28 13:50     ` Leon Romanovsky
     [not found]       ` <20170928135014.GY2297-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-09-29  2:05         ` Wei Hu (Xavier)
2017-09-28  4:57 ` [PATCH for-next 4/9] RDMA/hns: Set mask for destination qp field of qp context assignment Wei Hu (Xavier)
2017-09-28  4:57 ` [PATCH for-next 5/9] RDMA/hns: Set rdma_ah_attr type for querying qp Wei Hu (Xavier)
     [not found] ` <1506574654-56699-1-git-send-email-xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-09-28  4:57   ` [PATCH for-next 3/9] RDMA/hns: Add return statement when kzalloc return NULL in hns_roce_v1_recreate_lp_qp Wei Hu (Xavier)
     [not found]     ` <1506574654-56699-4-git-send-email-xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-09-28  9:13       ` Leon Romanovsky
2017-09-28 11:56         ` Wei Hu (Xavier)
2017-09-28 12:59           ` Leon Romanovsky [this message]
     [not found]             ` <20170928125912.GU2297-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-09-29  6:07               ` Wei Hu (Xavier)
     [not found]                 ` <59CDE31A.5090707-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-09-29 10:23                   ` Leon Romanovsky
     [not found]                     ` <20170929102337.GK2297-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-09-29 13:15                       ` Wei Hu (Xavier)
2017-09-28  4:57   ` [PATCH for-next 6/9] RDMA/hns: Add return statement when checking error in hns_roce_v1_mr_free_work_fn Wei Hu (Xavier)
2017-09-28  4:57   ` [PATCH for-next 8/9] RDMA/hns: Remove unused struct members in hns-abi.h Wei Hu (Xavier)
     [not found]     ` <1506574654-56699-9-git-send-email-xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-09-28  9:02       ` Leon Romanovsky
     [not found]         ` <20170928090203.GS2297-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-09-28 11:56           ` Wei Hu (Xavier)
2017-09-28 13:04             ` Leon Romanovsky
     [not found]               ` <20170928130437.GV2297-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-09-28 16:12                 ` Wei Hu (Xavier)
2017-09-28  4:57   ` [PATCH for-next 9/9] RDMA/hns: Replace usleep_range with udelay when checking command status Wei Hu (Xavier)
2017-09-28  4:57 ` [PATCH for-next 7/9] RDMA/hns: Remove unnecessarily calling unregister_inetaddr_notifier function Wei Hu (Xavier)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170928125912.GU2297@mtr-leonro.local \
    --to=leon@kernel.org \
    --cc=charles.chenxin@huawei.com \
    --cc=dledford@redhat.com \
    --cc=lijun_nudt@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=liuyixian@huawei.com \
    --cc=oulijun@huawei.com \
    --cc=shaobohsu@163.com \
    --cc=xavier.huwei@huawei.com \
    --cc=xavier.huwei@tom.com \
    --cc=xushaobo2@huawei.com \
    --cc=zhangxiping3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox