kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Colin King <colin.king@canonical.com>
Cc: Jianyun Li <jyli@marvell.com>,
	"James E . J . Bottomley" <jejb@linux.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: mvumi: fix 32 bit shift of a u32 value
Date: Wed, 14 Aug 2019 07:17:15 +0000	[thread overview]
Message-ID: <5D53B57B.3000905@bfs.de> (raw)
In-Reply-To: <20190813180113.14245-1-colin.king@canonical.com>



Am 13.08.2019 20:01, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the top 32 bits of a 64 bit address is being calculated
> by shifting a u32 twice by 16 bits and then being cast into a 64
> bit address.  Shifting a u32 twice by 16 bits always ends up with
> a zero.  Fix this by casting the u32 to a 64 bit address first
> and then shifting it 32 bits.
> 
> Addresses-Coverity: ("Operands don't affect result")
> Fixes: f0c568a478f0 ("[SCSI] mvumi: Add Marvell UMI driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/scsi/mvumi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
> index 8906aceda4c4..62df69f1e71e 100644
> --- a/drivers/scsi/mvumi.c
> +++ b/drivers/scsi/mvumi.c
> @@ -296,7 +296,7 @@ static void mvumi_delete_internal_cmd(struct mvumi_hba *mhba,
>  			sgd_getsz(mhba, m_sg, size);
>  
>  			phy_addr = (dma_addr_t) m_sg->baseaddr_l |
> -				(dma_addr_t) ((m_sg->baseaddr_h << 16) << 16);
> +				   (dma_addr_t) m_sg->baseaddr_h << 32;
>  

All the casts make it hard to read, i would propose an alternativ version:
phy_addr = m_sg->baseaddr_h;
phy_addr <<= 32;
phy_addr |= m_sg->baseaddr_l;

JM2C and totaly untested.

re,
 wh

>  			dma_free_coherent(&mhba->pdev->dev, size, cmd->data_buf,
>  								phy_addr);

  reply	other threads:[~2019-08-14  7:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-16 14:44 [PATCH] scsi: mvumi: fix 32 bit shift of a 32 bit unsigned int Colin King
2019-02-16 16:27 ` Walter Harms
2019-02-18  9:37   ` Dan Carpenter
2019-02-18 15:32     ` James Bottomley
2019-02-18 15:47       ` Dan Carpenter
2019-02-18 12:42 ` Walter Harms
2019-02-18 14:24 ` Dan Carpenter
2019-02-18 16:52 ` Walter Harms
2019-08-13 18:01 ` [PATCH] scsi: mvumi: fix 32 bit shift of a u32 value Colin King
2019-08-14  7:17   ` walter harms [this message]
2019-08-14  8:07   ` Dan Carpenter
2019-08-14 15:07   ` kbuild test robot

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=5D53B57B.3000905@bfs.de \
    --to=wharms@bfs.de \
    --cc=colin.king@canonical.com \
    --cc=jejb@linux.ibm.com \
    --cc=jyli@marvell.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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;
as well as URLs for NNTP newsgroup(s).