summaryrefslogtreecommitdiffstats
path: root/drivers/staging/unisys/visorbus/visorchannel.c
diff options
context:
space:
mode:
authorJes Sorensen2015-05-06 00:36:56 +0200
committerGreg Kroah-Hartman2015-05-08 15:27:29 +0200
commit0abb60c1c5c32be56e5a67fcc437fcd18e38c2b2 (patch)
treee6774f94aa6887c605a8e768693c54ba9527b5c0 /drivers/staging/unisys/visorbus/visorchannel.c
parentstaging: unisys: visorchannel_read(): Use memcpy_fromio() directly (diff)
downloadkernel-qcow2-linux-0abb60c1c5c32be56e5a67fcc437fcd18e38c2b2.tar.gz
kernel-qcow2-linux-0abb60c1c5c32be56e5a67fcc437fcd18e38c2b2.tar.xz
kernel-qcow2-linux-0abb60c1c5c32be56e5a67fcc437fcd18e38c2b2.zip
staging: unisys: visorchannel_write(): Handle partial channel_header writes
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.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index cae62fedab79..da7bd9c362f7 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -213,13 +213,16 @@ int
visorchannel_write(struct visorchannel *channel, ulong offset,
void *local, ulong nbytes)
{
- size_t size = sizeof(struct channel_header);
+ size_t chdr_size = sizeof(struct channel_header);
+ size_t copy_size;
if (offset + nbytes > channel->memregion.nbytes)
return -EIO;
- if (!offset && nbytes >= size)
- memcpy(&channel->chan_hdr, local, size);
+ if (offset < chdr_size) {
+ copy_size = min(chdr_size, nbytes) - offset;
+ memcpy(&channel->chan_hdr + offset, local, copy_size);
+ }
memcpy_toio(channel->memregion.mapped + offset, local, nbytes);