lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d87d208b-5fc7-8675-e07a-69c7665b32e5@ispras.ru>
Date:   Thu, 20 Apr 2023 22:02:57 +0300
From:   Alexey Khoroshilov <khoroshilov@...ras.ru>
To:     Peter Kosyh <pkosyh@...dex.ru>, Hannes Reinecke <hare@...nel.org>
Cc:     lvc-project@...uxtesting.org,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        linux-kernel@...r.kernel.org, linux-scsi@...r.kernel.org
Subject: Re: [PATCH] scsi: myrs: check return value of dma_alloc_coherent()
 instead of using dma_mapping_error()

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@...dex.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@...ras.ru>

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

--
Alexey

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ