summaryrefslogtreecommitdiffstats
path: root/drivers/staging/unisys/visorbus/visorchannel.c
diff options
context:
space:
mode:
authorJes Sorensen2015-05-06 00:36:55 +0200
committerGreg Kroah-Hartman2015-05-08 15:27:29 +0200
commit36203e71a0604baa547a6706b5e70ee2830a2407 (patch)
tree9a4c66f43c89e53b919d67239339b6822d4e43bb /drivers/staging/unisys/visorbus/visorchannel.c
parentstaging: unisys: visorchannel_write(): Use memcpy_toio() directly (diff)
downloadkernel-qcow2-linux-36203e71a0604baa547a6706b5e70ee2830a2407.tar.gz
kernel-qcow2-linux-36203e71a0604baa547a6706b5e70ee2830a2407.tar.xz
kernel-qcow2-linux-36203e71a0604baa547a6706b5e70ee2830a2407.zip
staging: unisys: visorchannel_read(): Use memcpy_fromio() directly
Note, this changes the behavior of visorchannel_read(). The old code would return the channel header, if the offset argument was 0, and the caller tried to read beyond the size of the visorchannel. Note this only worked for offset == 0, but not for (offset > 0) && (offset < header_size), which was inconsistent. The new implementation returns an error if someone tries to read beyond the visorchannel size. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/unisys/visorbus/visorchannel.c')
-rw-r--r--drivers/staging/unisys/visorbus/visorchannel.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index bf75aa075b74..cae62fedab79 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -200,13 +200,12 @@ int
visorchannel_read(struct visorchannel *channel, ulong offset,
void *local, ulong nbytes)
{
- int rc;
- size_t size = sizeof(struct channel_header);
+ if (offset + nbytes > channel->memregion.nbytes)
+ return -EIO;
- rc = visor_memregion_read(&channel->memregion, offset, local, nbytes);
- if (rc && !offset && (nbytes >= size))
- memcpy(&channel->chan_hdr, local, size);
- return rc;
+ memcpy_fromio(local, channel->memregion.mapped + offset, nbytes);
+
+ return 0;
}
EXPORT_SYMBOL_GPL(visorchannel_read);