From: Jes Sorensen Date: Tue, 5 May 2015 22:36:56 +0000 (-0400) Subject: staging: unisys: visorchannel_write(): Handle partial channel_header writes X-Git-Tag: v4.2-rc1~88^2~782 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0abb60c1c5c32be56e5a67fcc437fcd18e38c2b2;p=platform%2Fkernel%2Flinux-exynos.git staging: unisys: visorchannel_write(): Handle partial channel_header writes Signed-off-by: Jes Sorensen Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index cae62fed..da7bd9c 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);