mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Khoroshilov <khoroshilov@ispras.ru>
To: Peter Kosyh <pkosyh@yandex.ru>, Hannes Reinecke <hare@kernel.org>
Cc: lvc-project@linuxtesting.org,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: myrs: check return value of dma_alloc_coherent() instead of using dma_mapping_error()
Date: Thu, 20 Apr 2023 22:02:57 +0300	[thread overview]
Message-ID: <d87d208b-5fc7-8675-e07a-69c7665b32e5@ispras.ru> (raw)
In-Reply-To: <20221116094147.221640-1-pkosyh@yandex.ru>

On 16.11.2022 12:41, Peter Kosyh wrote:
> dma_alloc_coherent() may leave third parameter uninitialized. So
> it is not safe to use dma_mapping_error() without checking return
> value of dma_alloc_coherent().
> 
> Check the return value of dma_alloc_coherent() to detect
> an error.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Peter Kosyh <pkosyh@yandex.ru>
> ---
>  drivers/scsi/myrs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
> index 7eb8c39da366..1811c1a6385b 100644
> --- a/drivers/scsi/myrs.c
> +++ b/drivers/scsi/myrs.c
> @@ -498,14 +498,14 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs,
>  	/* Temporary dma mapping, used only in the scope of this function */
>  	mbox = dma_alloc_coherent(&pdev->dev, sizeof(union myrs_cmd_mbox),
>  				  &mbox_addr, GFP_KERNEL);
> -	if (dma_mapping_error(&pdev->dev, mbox_addr))
> +	if (!mbox)
>  		return false;
>  
>  	/* These are the base addresses for the command memory mailbox array */
>  	cs->cmd_mbox_size = MYRS_MAX_CMD_MBOX * sizeof(union myrs_cmd_mbox);
>  	cmd_mbox = dma_alloc_coherent(&pdev->dev, cs->cmd_mbox_size,
>  				      &cs->cmd_mbox_addr, GFP_KERNEL);
> -	if (dma_mapping_error(&pdev->dev, cs->cmd_mbox_addr)) {
> +	if (!cmd_mbox) {
>  		dev_err(&pdev->dev, "Failed to map command mailbox\n");
>  		goto out_free;
>  	}
> 

Reviewed-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

Also you may want to add
Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI
interface)")

--
Alexey

      reply	other threads:[~2023-04-20 19:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16  9:41 Peter Kosyh
2023-04-20 19:02 ` Alexey Khoroshilov [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=d87d208b-5fc7-8675-e07a-69c7665b32e5@ispras.ru \
    --to=khoroshilov@ispras.ru \
    --cc=hare@kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=martin.petersen@oracle.com \
    --cc=pkosyh@yandex.ru \
    /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

all inboxes | Powered by JetHome®