From mboxrd@z Thu Jan 1 00:00:00 1970 From: keith.busch@intel.com (Keith Busch) Date: Thu, 28 May 2015 22:35:49 +0000 (UTC) Subject: [PATCH] NVMe: fix type warning on 32-bit In-Reply-To: <2271255.ypbMPZa6tA@wuerfel> References: <2271255.ypbMPZa6tA@wuerfel> Message-ID: 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 > Signed-off-by: Arnd Bergmann > 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); > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754916AbbE1WgO (ORCPT ); Thu, 28 May 2015 18:36:14 -0400 Received: from mga09.intel.com ([134.134.136.24]:6370 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754577AbbE1WgF (ORCPT ); Thu, 28 May 2015 18:36:05 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,514,1427785200"; d="scan'208";a="578478877" Date: Thu, 28 May 2015 22:35:49 +0000 (UTC) From: Keith Busch X-X-Sender: vmware@localhost.lm.intel.com To: Arnd Bergmann cc: Jens Axboe , Keith Busch , linux-nvme@lists.infradead.org, Matthew Wilcox , linux-kernel@vger.kernel.org Subject: Re: [PATCH] NVMe: fix type warning on 32-bit In-Reply-To: <2271255.ypbMPZa6tA@wuerfel> Message-ID: References: <2271255.ypbMPZa6tA@wuerfel> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Arnd Bergmann > 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); > >