From 5d0a9c7932c45435de72b5a5b2825c7eb34186a4 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Sat, 21 Nov 2009 15:07:14 +0000 Subject: [PATCH] USB: cxacru: check data length is not negative When attempting to read data that is not actually an array of values, the length may be negative which causes an Oops due to a likely access off the end of the data array. This bug should not occur under normal use unless the device returns an invalid response. Signed-off-by: Simon Arlott Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/cxacru.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 4a26a6c93bec..8da4a06bf140 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -596,7 +596,7 @@ static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_requ len = ret / 4; for (offb = 0; offb < len; ) { int l = le32_to_cpu(buf[offb++]); - if (l > stride || l > (len - offb) / 2) { + if (l < 0 || l > stride || l > (len - offb) / 2) { if (printk_ratelimit()) usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n", cm, l); -- 2.30.2