The variable 'n' is initialized before "goto usbtmc_clear_check_status" looping, and used in inside "do ... while" looping,
So it may be not less than 'USBTMC_MAX_READS_TO_CLEAR_BULK_IN', need add related checking for it before the looping "do ... while". Signed-off-by: Chen Gang <gang.c...@asianux.com> --- drivers/usb/class/usbtmc.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index 42d62c9..cc137c6 100644 --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c @@ -787,6 +787,14 @@ usbtmc_clear_check_status: } if (buffer[1] == 1) { + if (n >= USBTMC_MAX_READS_TO_CLEAR_BULK_IN) { + dev_err(dev, + "Couldn't clear device buffer within %d cycles\n", + USBTMC_MAX_READS_TO_CLEAR_BULK_IN); + rv = -EPERM; + goto exit; + } + do { dev_dbg(dev, "Reading from bulk in EP\n"); -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html