All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/9] staging: otus: check kmalloc() return value
@ 2010-07-30 11:08 ` Kulikov Vasiliy
  0 siblings, 0 replies; 8+ messages in thread
From: Kulikov Vasiliy @ 2010-07-30 11:08 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Greg Kroah-Hartman, Alexander Beregalov, Tejun Heo,
	Mithlesh Thukral, devel, linux-kernel

kmalloc() may fail, if so return error from zfwUsbSubmitControl().

Signed-off-by: Kulikov Vasiliy <segooon@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;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/9] staging: otus: check kmalloc() return value
@ 2010-07-30 11:08 ` Kulikov Vasiliy
  0 siblings, 0 replies; 8+ messages in thread
From: Kulikov Vasiliy @ 2010-07-30 11:08 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Greg Kroah-Hartman, Alexander Beregalov, Tejun Heo,
	Mithlesh Thukral, devel, linux-kernel

kmalloc() may fail, if so return error from zfwUsbSubmitControl().

Signed-off-by: Kulikov Vasiliy <segooon@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;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/9] staging: otus: check kmalloc() return value
  2010-07-30 11:08 ` Kulikov Vasiliy
@ 2010-07-30 12:31   ` walter harms
  -1 siblings, 0 replies; 8+ messages in thread
From: walter harms @ 2010-07-30 12:31 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors, Greg Kroah-Hartman, Alexander Beregalov,
	Tejun Heo, Mithlesh Thukral, devel, linux-kernel



Kulikov Vasiliy schrieb:
> kmalloc() may fail, if so return error from zfwUsbSubmitControl().
> 
> Signed-off-by: Kulikov Vasiliy <segooon@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 ?

re,
 wh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/9] staging: otus: check kmalloc() return value
@ 2010-07-30 12:31   ` walter harms
  0 siblings, 0 replies; 8+ messages in thread
From: walter harms @ 2010-07-30 12:31 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors, Greg Kroah-Hartman, Alexander Beregalov,
	Tejun Heo, Mithlesh Thukral, devel, linux-kernel



Kulikov Vasiliy schrieb:
> kmalloc() may fail, if so return error from zfwUsbSubmitControl().
> 
> Signed-off-by: Kulikov Vasiliy <segooon@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 ?

re,
 wh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/9] staging: otus: check kmalloc() return value
  2010-07-30 12:31   ` walter harms
@ 2010-07-30 12:49     ` Jiri Slaby
  -1 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2010-07-30 12:49 UTC (permalink / raw)
  To: wharms
  Cc: Kulikov Vasiliy, devel, Greg Kroah-Hartman, kernel-janitors,
	linux-kernel, Tejun Heo

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@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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/9] staging: otus: check kmalloc() return value
@ 2010-07-30 12:49     ` Jiri Slaby
  0 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2010-07-30 12:49 UTC (permalink / raw)
  To: wharms
  Cc: Kulikov Vasiliy, devel, Greg Kroah-Hartman, kernel-janitors,
	linux-kernel, Tejun Heo

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@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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/9] staging: otus: check kmalloc() return value
  2010-07-30 11:08 ` Kulikov Vasiliy
@ 2010-07-30 14:07   ` Dan Carpenter
  -1 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2010-07-30 14:07 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors, Greg Kroah-Hartman, Alexander Beregalov,
	Tejun Heo, Mithlesh Thukral, devel, linux-kernel

On Fri, Jul 30, 2010 at 03:08:00PM +0400, Kulikov Vasiliy wrote:
>  	if (size > 0) {
>  		buf = kmalloc(size, GFP_KERNEL);
> +		if (buf = NULL) {
> +			pr_err("zfwUsbSubmitControl() failed, "
> +				  "kmalloc() returned NULL\n");

This isn't a big deal, but the pr_err() isn't needed.  kmalloc() already
prints a message unless __GFP_NOWARN is used.

regards,
dan carpenter



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/9] staging: otus: check kmalloc() return value
@ 2010-07-30 14:07   ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2010-07-30 14:07 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors, Greg Kroah-Hartman, Alexander Beregalov,
	Tejun Heo, Mithlesh Thukral, devel, linux-kernel

On Fri, Jul 30, 2010 at 03:08:00PM +0400, Kulikov Vasiliy wrote:
>  	if (size > 0) {
>  		buf = kmalloc(size, GFP_KERNEL);
> +		if (buf == NULL) {
> +			pr_err("zfwUsbSubmitControl() failed, "
> +				  "kmalloc() returned NULL\n");

This isn't a big deal, but the pr_err() isn't needed.  kmalloc() already
prints a message unless __GFP_NOWARN is used.

regards,
dan carpenter



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-07-30 14:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-30 11:08 [PATCH 3/9] staging: otus: check kmalloc() return value Kulikov Vasiliy
2010-07-30 11:08 ` Kulikov Vasiliy
2010-07-30 12:31 ` walter harms
2010-07-30 12:31   ` walter harms
2010-07-30 12:49   ` Jiri Slaby
2010-07-30 12:49     ` Jiri Slaby
2010-07-30 14:07 ` Dan Carpenter
2010-07-30 14:07   ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.