vhost: fix sparse warnings
Subsystems (2)
PATCH 1/1 vhost: fix sparse warnings
drivers/vhost/net.c +2 -2
@@ -641,7 +641,7 @@ static struct miscdevice vhost_net_misc &vhost_net_fops, }; -int vhost_net_init (void ) +static int vhost_net_init (void ) {int r =vhost_init ();if (r)
@@ -658,7 +658,7 @@ err_init: }module_init (vhost_net_init); -void vhost_net_exit (void ) +static void vhost_net_exit (void ) {misc_deregister (&vhost_net_misc);vhost_cleanup ();
drivers/vhost/vhost.c +5 -4
@@ -710,7 +710,7 @@ int vhost_log_write(struct vhost_virtquereturn 0 ; } -int translate_desc (struct vhost_dev *dev,u64 addr,u32 len, +static int translate_desc (struct vhost_dev *dev,u64 addr,u32 len,struct iovec iov[],int iov_size) {const struct vhost_memory_region *reg;
@@ -736,7 +736,7 @@ int translate_desc(struct vhost_dev *dev _iov = iov + ret; size = reg->memory_size - addr + reg->guest_phys_addr; _iov->iov_len =min ((u64 )len, size); - _iov->iov_base = (void *)(unsigned long ) + _iov->iov_base = (void __user *)(unsigned long ) (reg->userspace_addr + addr - reg->guest_phys_addr); s += size; addr += size;
@@ -990,7 +990,7 @@ void vhost_discard_vq_desc(struct vhost_* want to notify the guest, using eventfd. */ int vhost_add_used (struct vhost_virtqueue *vq,unsigned int head,int len) { -struct vring_used_elem *used; +struct vring_used_elem __user *used;/* The virtqueue contains a ring of used buffers. Get a pointer to the * next entry in that used ring. */
@@ -1014,7 +1014,8 @@ int vhost_add_used(struct vhost_virtqueusmp_wmb ();/* Log used ring entry write. */ log_write (vq->log_base, - vq->log_addr + ((void *)used - (void *)vq->used), + vq->log_addr + + ((void __user *)used - (void __user *)vq->used),sizeof *used);/* Log used index update. */ log_write(vq->log_base,
Michael S. Tsirkin
maintainerCan you add a Signed-off-by line please?
Quoted 64 lines · Christoph Hellwig
Index:
linux-2.6/drivers/vhost/net.c
===================================================================drivers/vhost/net.c +2
-2@@ -641,7 +641,7 @@ static struct miscdevice vhost_net_misc &vhost_net_fops, }; -int vhost_net_init (void ) +static int vhost_net_init (void ) {int r =vhost_init ();if (r)@@ -658,7 +658,7 @@ err_init: }module_init (vhost_net_init); -void vhost_net_exit (void ) +static void vhost_net_exit (void ) {misc_deregister (&vhost_net_misc);vhost_cleanup ();Index:
linux-2.6/drivers/vhost/vhost.c
===================================================================drivers/vhost/vhost.c +5
-4@@ -710,7 +710,7 @@ int vhost_log_write(struct vhost_virtquereturn 0 ; } -int translate_desc (struct vhost_dev *dev,u64 addr,u32 len, +static int translate_desc (struct vhost_dev *dev,u64 addr,u32 len,struct iovec iov[],int iov_size) {const struct vhost_memory_region *reg;@@ -736,7 +736,7 @@ int translate_desc(struct vhost_dev *dev _iov = iov + ret; size = reg->memory_size - addr + reg->guest_phys_addr; _iov->iov_len =min ((u64 )len, size); - _iov->iov_base = (void *)(unsigned long ) + _iov->iov_base = (void __user *)(unsigned long ) (reg->userspace_addr + addr - reg->guest_phys_addr); s += size; addr += size;@@ -990,7 +990,7 @@ void vhost_discard_vq_desc(struct vhost_* want to notify the guest, using eventfd. */ int vhost_add_used (struct vhost_virtqueue *vq,unsigned int head,int len) { -struct vring_used_elem *used; +struct vring_used_elem __user *used;/* The virtqueue contains a ring of used buffers. Get a pointer to the * next entry in that used ring. */ @@ -1014,7 +1014,8 @@ int vhost_add_used(struct vhost_virtqueusmp_wmb ();/* Log used ring entry write. */ log_write (vq->log_base, - vq->log_addr + ((void *)used - (void *)vq->used), + vq->log_addr + + ((void __user *)used - (void __user *)vq->used),sizeof *used);/* Log used index update. */ log_write(vq->log_base,
Signed-off-by Christoph Hellwig <[email protected]>
drivers/vhost/net.c +2 -2
@@ -641,7 +641,7 @@ static struct miscdevice vhost_net_misc &vhost_net_fops, }; -int vhost_net_init (void ) +static int vhost_net_init (void ) {int r =vhost_init ();if (r)
@@ -658,7 +658,7 @@ err_init: }module_init (vhost_net_init); -void vhost_net_exit (void ) +static void vhost_net_exit (void ) {misc_deregister (&vhost_net_misc);vhost_cleanup ();
drivers/vhost/vhost.c +5 -4
@@ -710,7 +710,7 @@ int vhost_log_write(struct vhost_virtquereturn 0 ; } -int translate_desc (struct vhost_dev *dev,u64 addr,u32 len, +static int translate_desc (struct vhost_dev *dev,u64 addr,u32 len,struct iovec iov[],int iov_size) {const struct vhost_memory_region *reg;
@@ -736,7 +736,7 @@ int translate_desc(struct vhost_dev *dev _iov = iov + ret; size = reg->memory_size - addr + reg->guest_phys_addr; _iov->iov_len =min ((u64 )len, size); - _iov->iov_base = (void *)(unsigned long ) + _iov->iov_base = (void __user *)(unsigned long ) (reg->userspace_addr + addr - reg->guest_phys_addr); s += size; addr += size;
@@ -990,7 +990,7 @@ void vhost_discard_vq_desc(struct vhost_* want to notify the guest, using eventfd. */ int vhost_add_used (struct vhost_virtqueue *vq,unsigned int head,int len) { -struct vring_used_elem *used; +struct vring_used_elem __user *used;/* The virtqueue contains a ring of used buffers. Get a pointer to the * next entry in that used ring. */
@@ -1014,7 +1014,8 @@ int vhost_add_used(struct vhost_virtqueusmp_wmb ();/* Log used ring entry write. */ log_write (vq->log_base, - vq->log_addr + ((void *)used - (void *)vq->used), + vq->log_addr + + ((void __user *)used - (void __user *)vq->used),sizeof *used);/* Log used index update. */ log_write(vq->log_base,
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>
Thanks, applied.
Quoted 63 lines
Index:
linux-2.6/drivers/vhost/net.c
===================================================================drivers/vhost/net.c +2
-2@@ -641,7 +641,7 @@ static struct miscdevice vhost_net_misc &vhost_net_fops, }; -int vhost_net_init (void ) +static int vhost_net_init (void ) {int r =vhost_init ();if (r)@@ -658,7 +658,7 @@ err_init: }module_init (vhost_net_init); -void vhost_net_exit (void ) +static void vhost_net_exit (void ) {misc_deregister (&vhost_net_misc);vhost_cleanup ();Index:
linux-2.6/drivers/vhost/vhost.c
===================================================================drivers/vhost/vhost.c +5
-4@@ -710,7 +710,7 @@ int vhost_log_write(struct vhost_virtquereturn 0 ; } -int translate_desc (struct vhost_dev *dev,u64 addr,u32 len, +static int translate_desc (struct vhost_dev *dev,u64 addr,u32 len,struct iovec iov[],int iov_size) {const struct vhost_memory_region *reg;@@ -736,7 +736,7 @@ int translate_desc(struct vhost_dev *dev _iov = iov + ret; size = reg->memory_size - addr + reg->guest_phys_addr; _iov->iov_len =min ((u64 )len, size); - _iov->iov_base = (void *)(unsigned long ) + _iov->iov_base = (void __user *)(unsigned long ) (reg->userspace_addr + addr - reg->guest_phys_addr); s += size; addr += size;@@ -990,7 +990,7 @@ void vhost_discard_vq_desc(struct vhost_* want to notify the guest, using eventfd. */ int vhost_add_used (struct vhost_virtqueue *vq,unsigned int head,int len) { -struct vring_used_elem *used; +struct vring_used_elem __user *used;/* The virtqueue contains a ring of used buffers. Get a pointer to the * next entry in that used ring. */ @@ -1014,7 +1014,8 @@ int vhost_add_used(struct vhost_virtqueusmp_wmb ();/* Log used ring entry write. */ log_write (vq->log_base, - vq->log_addr + ((void *)used - (void *)vq->used), + vq->log_addr + + ((void __user *)used - (void __user *)vq->used),sizeof *used);/* Log used index update. */ log_write(vq->log_base,