From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 8 Dec 2016 11:15:40 +0100
The functions "kcalloc" and "kzalloc" were called in four cases by the
function "usbduxsigma_alloc_usb_buffers" without checking immediately
if they succeded.
This issue was detected by using the Coccinelle software.
Allocated memory was also not released if one of these function
calls failed.
* Reduce memory allocation sizes for two function calls.
* Split a condition check for memory allocation failures.
* Add more exception handling.
Fixes: 65989c030bbca96be45ed137f6384dbd46030d10 ("staging: comedi: usbduxsigma: factor usb buffer allocation out of (*probe)")
Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
drivers/staging/comedi/drivers/usbduxsigma.c | 61 ++++++++++++++++++++++------
1 file changed, 49 insertions(+), 12 deletions(-)