diff options
| author | Michael S. Tsirkin <mst@redhat.com> | 2014-12-01 06:31:45 -0500 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2014-12-09 05:06:33 -0500 |
| commit | 48b36066b48025b7cd7d46c9a879f2f72fd9086a (patch) | |
| tree | d5a9f3eef7c7d4da573a7a671e34885043f55853 | |
| parent | 2e73c716ba22b3b3df56be25132df2774967f2b1 (diff) | |
virtio_console: fix sparse warnings
CHECK drivers/char/virtio_console.c
drivers/char/virtio_console.c:687:36: warning: incorrect type in
argument 1 (different address spaces)
drivers/char/virtio_console.c:687:36: expected void [noderef]
<asn:1>*to
drivers/char/virtio_console.c:687:36: got char *out_buf
drivers/char/virtio_console.c:790:35: warning: incorrect type in
argument 2 (different address spaces)
drivers/char/virtio_console.c:790:35: expected char *out_buf
drivers/char/virtio_console.c:790:35: got char [noderef]
<asn:1>*ubuf
fill_readbuf is reused with both kernel and userspace pointers,
depending on value of to_user flag.
Tag address parameter as __user, and cast to/from regular pointer type
when we know it's safe.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| -rw-r--r-- | drivers/char/virtio_console.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 6cc832b45185..de03df9dd7c9 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
| @@ -669,8 +669,8 @@ done: | |||
| 669 | * Give out the data that's requested from the buffer that we have | 669 | * Give out the data that's requested from the buffer that we have |
| 670 | * queued up. | 670 | * queued up. |
| 671 | */ | 671 | */ |
| 672 | static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count, | 672 | static ssize_t fill_readbuf(struct port *port, char __user *out_buf, |
| 673 | bool to_user) | 673 | size_t out_count, bool to_user) |
| 674 | { | 674 | { |
| 675 | struct port_buffer *buf; | 675 | struct port_buffer *buf; |
| 676 | unsigned long flags; | 676 | unsigned long flags; |
| @@ -688,7 +688,8 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count, | |||
| 688 | if (ret) | 688 | if (ret) |
| 689 | return -EFAULT; | 689 | return -EFAULT; |
| 690 | } else { | 690 | } else { |
| 691 | memcpy(out_buf, buf->buf + buf->offset, out_count); | 691 | memcpy((__force char *)out_buf, buf->buf + buf->offset, |
| 692 | out_count); | ||
| 692 | } | 693 | } |
| 693 | 694 | ||
| 694 | buf->offset += out_count; | 695 | buf->offset += out_count; |
| @@ -1162,7 +1163,7 @@ static int get_chars(u32 vtermno, char *buf, int count) | |||
| 1162 | /* If we don't have an input queue yet, we can't get input. */ | 1163 | /* If we don't have an input queue yet, we can't get input. */ |
| 1163 | BUG_ON(!port->in_vq); | 1164 | BUG_ON(!port->in_vq); |
| 1164 | 1165 | ||
| 1165 | return fill_readbuf(port, buf, count, false); | 1166 | return fill_readbuf(port, (__force char __user *)buf, count, false); |
| 1166 | } | 1167 | } |
| 1167 | 1168 | ||
| 1168 | static void resize_console(struct port *port) | 1169 | static void resize_console(struct port *port) |
