summaryrefslogtreecommitdiffstats
path: root/drivers/staging/unisys/visorbus/visorchannel.c
diff options
context:
space:
mode:
authorJes Sorensen2015-06-16 15:13:33 +0200
committerGreg Kroah-Hartman2015-06-16 23:36:39 +0200
commit56df900cb44d18c3ffaf16e09b83aaf37d912cc5 (patch)
treefbee1de66a2ee35d637cb7b27718c608e5c97caf /drivers/staging/unisys/visorbus/visorchannel.c
parentstaging: unisys: Add s-Par visornic ethernet driver (diff)
downloadkernel-qcow2-linux-56df900cb44d18c3ffaf16e09b83aaf37d912cc5.tar.gz
kernel-qcow2-linux-56df900cb44d18c3ffaf16e09b83aaf37d912cc5.tar.xz
kernel-qcow2-linux-56df900cb44d18c3ffaf16e09b83aaf37d912cc5.zip
staging: unisys: visorchannel_write() fix potential memory corruption
This fixes the memory corruption case, if nbytes is less than offset and sizeof(struct channel_header) Reported-by: Dan Carpenter <dan.carpenter@oracle.com> 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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index b1155ab9eeeb..20b63496e9f2 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -258,7 +258,7 @@ visorchannel_write(struct visorchannel *channel, ulong offset,
return -EIO;
if (offset < chdr_size) {
- copy_size = min(chdr_size, nbytes) - offset;
+ copy_size = min(chdr_size - offset, nbytes);
memcpy(&channel->chan_hdr + offset, local, copy_size);
}