public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <keith.busch@intel.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Jens Axboe <axboe@fb.com>, Keith Busch <keith.busch@intel.com>,
	linux-nvme@lists.infradead.org,
	Matthew Wilcox <willy@linux.intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] NVMe: fix type warning on 32-bit
Date: Thu, 28 May 2015 22:35:49 +0000 (UTC)	[thread overview]
Message-ID: <alpine.LNX.2.00.1505282235140.15930@localhost.lm.intel.com> (raw)
In-Reply-To: <2271255.ypbMPZa6tA@wuerfel>

On Tue, 19 May 2015, Arnd Bergmann wrote:
> A recent change to the ioctl handling caused a new harmless
> warning in the NVMe driver on all 32-bit machines:
>
> drivers/block/nvme-core.c: In function 'nvme_submit_io':
> drivers/block/nvme-core.c:1794:29: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
>
> In order to shup up that warning, this introduces a new
> temporary variable that uses a double cast to extract
> the pointer from an __u64 structure member.


Thanks for the fix.

Acked-by: Keith Busch <keith.busch@intel.com>

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: a67a95134ff ("NVMe: Meta data handling through submit io ioctl")
>
> diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
> index 85b8036deaa3..683dff272562 100644
> --- a/drivers/block/nvme-core.c
> +++ b/drivers/block/nvme-core.c
> @@ -1750,6 +1750,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
> 	struct nvme_iod *iod;
> 	dma_addr_t meta_dma = 0;
> 	void *meta = NULL;
> +	void __user *metadata;
>
> 	if (copy_from_user(&io, uio, sizeof(io)))
> 		return -EFAULT;
> @@ -1763,6 +1764,8 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
> 		meta_len = 0;
> 	}
>
> +	metadata = (void __user *)(unsigned long)io.metadata;
> +
> 	write = io.opcode & 1;
>
> 	switch (io.opcode) {
> @@ -1786,13 +1789,13 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
> 	if (meta_len) {
> 		meta = dma_alloc_coherent(&dev->pci_dev->dev, meta_len,
> 						&meta_dma, GFP_KERNEL);
> +
> 		if (!meta) {
> 			status = -ENOMEM;
> 			goto unmap;
> 		}
> 		if (write) {
> -			if (copy_from_user(meta, (void __user *)io.metadata,
> -								meta_len)) {
> +			if (copy_from_user(meta, metadata, meta_len)) {
> 				status = -EFAULT;
> 				goto unmap;
> 			}
> @@ -1819,8 +1822,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
> 	nvme_free_iod(dev, iod);
> 	if (meta) {
> 		if (status == NVME_SC_SUCCESS && !write) {
> -			if (copy_to_user((void __user *)io.metadata, meta,
> -								meta_len))
> +			if (copy_to_user(metadata, meta, meta_len))
> 				status = -EFAULT;
> 		}
> 		dma_free_coherent(&dev->pci_dev->dev, meta_len, meta, meta_dma);
>
>

  reply	other threads:[~2015-05-28 22:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 15:05 [PATCH] NVMe: fix type warning on 32-bit Arnd Bergmann
2015-05-28 22:35 ` Keith Busch [this message]
2015-05-29 16:06   ` Jens Axboe

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=alpine.LNX.2.00.1505282235140.15930@localhost.lm.intel.com \
    --to=keith.busch@intel.com \
    --cc=arnd@arndb.de \
    --cc=axboe@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=willy@linux.intel.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