summaryrefslogtreecommitdiff
path: root/drivers/watchdog/i6300esb.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2011-12-08 18:35:51 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2011-12-08 12:16:34 -0800
commita1e44d6ac5577b78ec85833b22d58345b2758ebb (patch)
treef88ca5aa6d5dbfcb10eee3c3f5aa9f3bc037bfc8 /drivers/watchdog/i6300esb.c
parentc6795ad4c7934a1db196697308ea0c3ac8b15f52 (diff)
staging:iio: Fix sw_ring memory corruption
The sw_ring does not properly handle the case where the write pointer already has wrapped around, the read pointer has not and the remaining buffer space at the end is enough to fill the read buffer: +-----------------------------------+ | | |##data##| | +-----------------------------------+ write_p read_p In this case the current code will copy all available data to the buffer and as a result will write beyond the bounds of the buffer and cause a memory corruption. To address this issue this patch adds code to calculate the available buffer space and makes sure that the number of bytes to copy does not exceed this number. This allows the code which copies the data around to be simplified as it only has to consider two cases: Read wraps around and read does not wrap around. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/watchdog/i6300esb.c')
0 files changed, 0 insertions, 0 deletions