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>
This commit is contained in:
parent
36203e71a0
commit
0abb60c1c5
@ -213,13 +213,16 @@ int
|
|||||||
visorchannel_write(struct visorchannel *channel, ulong offset,
|
visorchannel_write(struct visorchannel *channel, ulong offset,
|
||||||
void *local, ulong nbytes)
|
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)
|
if (offset + nbytes > channel->memregion.nbytes)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
if (!offset && nbytes >= size)
|
if (offset < chdr_size) {
|
||||||
memcpy(&channel->chan_hdr, local, size);
|
copy_size = min(chdr_size, nbytes) - offset;
|
||||||
|
memcpy(&channel->chan_hdr + offset, local, copy_size);
|
||||||
|
}
|
||||||
|
|
||||||
memcpy_toio(channel->memregion.mapped + offset, local, nbytes);
|
memcpy_toio(channel->memregion.mapped + offset, local, nbytes);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user