Skip to content

Commit

Permalink
staging: unisys: visorchannel_write(): Handle partial channel_header …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
Jes Sorensen authored and Greg Kroah-Hartman committed May 8, 2015
1 parent 36203e7 commit 0abb60c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/staging/unisys/visorbus/visorchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 0abb60c

Please sign in to comment.