public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Cc: <dledford@redhat.com>, <linux-rdma@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] IB/mthca: fix return value of error branch in mthca_init_cq()
Date: Thu, 19 Nov 2020 11:30:50 -0400	[thread overview]
Message-ID: <20201119153050.GA1960484@nvidia.com> (raw)
In-Reply-To: <1605789529-54808-1-git-send-email-wangxiongfeng2@huawei.com>

On Thu, Nov 19, 2020 at 08:38:49PM +0800, Xiongfeng Wang wrote:
> We return 'err' in the error branch, but this variable may be set as
> zero by the above code. Fix it by setting 'err'  as a negative value
> before we goto the error label.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>

Missing fixes line

>  drivers/infiniband/hw/mthca/mthca_cq.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
> index c3cfea2..98d697b 100644
> --- a/drivers/infiniband/hw/mthca/mthca_cq.c
> +++ b/drivers/infiniband/hw/mthca/mthca_cq.c
> @@ -803,8 +803,10 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
>  	}
>  
>  	mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
> -	if (IS_ERR(mailbox))
> +	if (IS_ERR(mailbox)) {
> +		err = -ENOMEM;
>  		goto err_out_arm;
> +	}

mthca_alloc_mailbox returns err_ptr so this should do 

   err = ERR_PTR(mailbox)

>  	cq_context = mailbox->buf;
>  
> @@ -850,6 +852,7 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
>  			    cq->cqn & (dev->limits.num_cqs - 1),
>  			    cq)) {
>  		spin_unlock_irq(&dev->cq_table.lock);
> +		err = -ENOMEM;

And this should assign err to the output of mthca_array_set

Please fix and resend.

Thanks,
Jason

  reply	other threads:[~2020-11-19 15:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19 12:38 [PATCH] IB/mthca: fix return value of error branch in mthca_init_cq() Xiongfeng Wang
2020-11-19 15:30 ` Jason Gunthorpe [this message]
2020-11-20  1:51   ` Xiongfeng Wang

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=20201119153050.GA1960484@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=dledford@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=wangxiongfeng2@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