diff options
| author | Jes Sorensen <[email protected]> | 2015-05-05 18:36:56 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <[email protected]> | 2015-05-08 15:27:29 +0200 |
| commit | 0abb60c1c5c32be56e5a67fcc437fcd18e38c2b2 (patch) | |
| tree | e6774f94aa6887c605a8e768693c54ba9527b5c0 | |
| parent | 36203e71a0604baa547a6706b5e70ee2830a2407 (diff) | |
staging: unisys: visorchannel_write(): Handle partial channel_header writes
Signed-off-by: Jes Sorensen <[email protected]>
Signed-off-by: Benjamin Romer <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
| -rw-r--r-- | drivers/staging/unisys/visorbus/visorchannel.c | 9 |
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); |