staging: unisys: visorchannel_write() fix potential memory corruption
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 16 Jun 2015 13:13:33 +0000 (09:13 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 16 Jun 2015 21:36:39 +0000 (14:36 -0700)
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>
drivers/staging/unisys/visorbus/visorchannel.c

index b1155ab9eeeb4a5246e666cd1d4d3a1f76a44978..20b63496e9f215a51e6385fd0d2e4b96b8758e75 100644 (file)
@@ -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);
        }
 
This page took 0.024626 seconds and 5 git commands to generate.