public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jon Mason <jdmason@kudzu.us>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Serge Semin <fancer.lancer@gmail.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Allen Hubbe <allenbh@gmail.com>,
	linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] NTB: ntb_hw_idt: replace IS_ERR_OR_NULL with regular NULL checks
Date: Wed, 31 Oct 2018 16:34:42 -0400	[thread overview]
Message-ID: <20181031203441.GB22474@kudzu.us> (raw)
In-Reply-To: <20180827221306.GA8936@embeddedor.com>

On Mon, Aug 27, 2018 at 05:13:06PM -0500, Gustavo A. R. Silva wrote:
> Both devm_kcalloc() and devm_kzalloc() return NULL on error. They
> never return error pointers.
> 
> The use of IS_ERR_OR_NULL is currently applied to the wrong
> context.
> 
> Fix this by replacing IS_ERR_OR_NULL with regular NULL checks.
> 
> Fixes: bf2a952d31d2 ("NTB: Add IDT 89HPESxNTx PCIe-switches support")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied to my ntb branch

Thanks,
Jon

> ---
>  drivers/ntb/hw/idt/ntb_hw_idt.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/ntb/hw/idt/ntb_hw_idt.c b/drivers/ntb/hw/idt/ntb_hw_idt.c
> index dbe72f1..a67ef23 100644
> --- a/drivers/ntb/hw/idt/ntb_hw_idt.c
> +++ b/drivers/ntb/hw/idt/ntb_hw_idt.c
> @@ -1105,9 +1105,9 @@ static struct idt_mw_cfg *idt_scan_mws(struct idt_ntb_dev *ndev, int port,
>  	}
>  
>  	/* Allocate memory for memory window descriptors */
> -	ret_mws = devm_kcalloc(&ndev->ntb.pdev->dev, *mw_cnt,
> -				sizeof(*ret_mws), GFP_KERNEL);
> -	if (IS_ERR_OR_NULL(ret_mws))
> +	ret_mws = devm_kcalloc(&ndev->ntb.pdev->dev, *mw_cnt, sizeof(*ret_mws),
> +			       GFP_KERNEL);
> +	if (!ret_mws)
>  		return ERR_PTR(-ENOMEM);
>  
>  	/* Copy the info of detected memory windows */
> @@ -2390,7 +2390,7 @@ static struct idt_ntb_dev *idt_create_dev(struct pci_dev *pdev,
>  
>  	/* Allocate memory for the IDT PCIe-device descriptor */
>  	ndev = devm_kzalloc(&pdev->dev, sizeof(*ndev), GFP_KERNEL);
> -	if (IS_ERR_OR_NULL(ndev)) {
> +	if (!ndev) {
>  		dev_err(&pdev->dev, "Memory allocation failed for descriptor");
>  		return ERR_PTR(-ENOMEM);
>  	}
> -- 
> 2.7.4
> 

      reply	other threads:[~2018-10-31 20:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-27 22:13 [PATCH] NTB: ntb_hw_idt: replace IS_ERR_OR_NULL with regular NULL checks Gustavo A. R. Silva
2018-10-31 20:34 ` Jon Mason [this message]

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=20181031203441.GB22474@kudzu.us \
    --to=jdmason@kudzu.us \
    --cc=allenbh@gmail.com \
    --cc=dave.jiang@intel.com \
    --cc=fancer.lancer@gmail.com \
    --cc=gustavo@embeddedor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ntb@googlegroups.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