From: Dan Carpenter Date: Tue, 5 Nov 2013 05:55:18 +0000 (+1100) Subject: drivers/block/paride/pg.c: underflow bug in pg_write() X-Git-Tag: next-20131105~2^2~282 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b250fd71d0f60860af88a8e35b96f85244e7dc58;p=karo-tx-linux.git drivers/block/paride/pg.c: underflow bug in pg_write() The test here can underflow so we pass bogus lengths to the hardware. It's a static checker fix and I don't know the impact. Signed-off-by: Dan Carpenter Cc: Jens Axboe Signed-off-by: Andrew Morton --- diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c index 4a27b1de5fcb..2ce3dfd7e6b9 100644 --- a/drivers/block/paride/pg.c +++ b/drivers/block/paride/pg.c @@ -581,7 +581,7 @@ static ssize_t pg_write(struct file *filp, const char __user *buf, size_t count, if (hdr.magic != PG_MAGIC) return -EINVAL; - if (hdr.dlen > PG_MAX_DATA) + if (hdr.dlen < 0 || hdr.dlen > PG_MAX_DATA) return -EINVAL; if ((count - hs) > PG_MAX_DATA) return -EINVAL;