[PATCH 3/9] staging: otus: check kmalloc() return value

Jiri Slaby jirislaby at gmail.com
Fri Jul 30 12:49:25 UTC 2010


On 07/30/2010 02:31 PM, walter harms wrote:
> 
> 
> Kulikov Vasiliy schrieb:
>> kmalloc() may fail, if so return error from zfwUsbSubmitControl().
>>
>> Signed-off-by: Kulikov Vasiliy <segooon at gmail.com>
>> ---
>>  drivers/staging/otus/wrap_usb.c |    5 +++++
>>  1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/staging/otus/wrap_usb.c b/drivers/staging/otus/wrap_usb.c
>> index 93459ca..9f04047 100644
>> --- a/drivers/staging/otus/wrap_usb.c
>> +++ b/drivers/staging/otus/wrap_usb.c
>> @@ -104,6 +104,11 @@ u32_t zfwUsbSubmitControl(zdev_t *dev, u8_t req, u16_t value, u16_t index,
>>  
>>  	if (size > 0) {
>>  		buf = kmalloc(size, GFP_KERNEL);
>> +		if (buf == NULL) {
>> +			pr_err("zfwUsbSubmitControl() failed, "
>> +				  "kmalloc() returned NULL\n");
>> +			return 1;
>> +		}
>>  		memcpy(buf, (u8_t *)data, size);
>>  	} else
>>  		buf = NULL;
> 
> 
> We had a memdup() somewhere had'nt we ?

Yes, but it is not what he is changing. (Patches welcome.)

The patch is OK, except try to avoid function names in printks next
time. Function names are constantly changing, but developers tend not to
change printk strings. (%s + __func__)

regards,
-- 
js



More information about the devel mailing list