staging: comedi: avoid bad truncation of a size_t in comedi_write()
authorIan Abbott <abbotti@mev.co.uk>
Wed, 18 Nov 2015 17:55:07 +0000 (17:55 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Dec 2015 23:58:54 +0000 (15:58 -0800)
commit591c5f8a599a58c7c3773027010e537fc1d7a7d5
tree13612d7e3c14fec4185ed0bc0b829bf3bef83b79
parent84a185ec429fe64e5b0d81d7ac815c91578ee569
staging: comedi: avoid bad truncation of a size_t in comedi_write()

At one point in `comedi_write()`, the variable `n` gets assigned to the
minimum of the parameter `nbytes` and the amount of writeable buffer
space.  The way that is done currently is unsafe in the unlikely case
that `nbytes` exceeds `UINT_MAX`, so fix it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/comedi_fops.c