All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] ieee802154: Use kmemdup instead of duplicating it in ca8210_test_int_driver_write
@ 2018-08-09  6:44 ` YueHaibing
  0 siblings, 0 replies; 7+ messages in thread
From: YueHaibing @ 2018-08-09  6:44 UTC (permalink / raw)
  To: davem, h.morris, alex.aring, stefan
  Cc: linux-kernel, netdev, linux-wpan, YueHaibing

Replace calls to kmalloc followed by a memcpy with a direct call to
kmemdup.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ieee802154/ca8210.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index 58299fb..e21279d 100644
--- a/drivers/net/ieee802154/ca8210.c
+++ b/drivers/net/ieee802154/ca8210.c
@@ -634,10 +634,9 @@ static int ca8210_test_int_driver_write(
 	for (i = 0; i < len; i++)
 		dev_dbg(&priv->spi->dev, "%#03x\n", buf[i]);
 
-	fifo_buffer = kmalloc(len, GFP_KERNEL);
+	fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
 	if (!fifo_buffer)
 		return -ENOMEM;
-	memcpy(fifo_buffer, buf, len);
 	kfifo_in(&test->up_fifo, &fifo_buffer, 4);
 	wake_up_interruptible(&priv->test.readq);
 
-- 
2.7.0



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

* [PATCH net-next] ieee802154: Use kmemdup instead of duplicating it in ca8210_test_int_driver_write
@ 2018-08-09  6:44 ` YueHaibing
  0 siblings, 0 replies; 7+ messages in thread
From: YueHaibing @ 2018-08-09  6:44 UTC (permalink / raw)
  To: davem, h.morris, alex.aring, stefan
  Cc: linux-kernel, netdev, linux-wpan, YueHaibing

Replace calls to kmalloc followed by a memcpy with a direct call to
kmemdup.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ieee802154/ca8210.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index 58299fb..e21279d 100644
--- a/drivers/net/ieee802154/ca8210.c
+++ b/drivers/net/ieee802154/ca8210.c
@@ -634,10 +634,9 @@ static int ca8210_test_int_driver_write(
 	for (i = 0; i < len; i++)
 		dev_dbg(&priv->spi->dev, "%#03x\n", buf[i]);
 
-	fifo_buffer = kmalloc(len, GFP_KERNEL);
+	fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
 	if (!fifo_buffer)
 		return -ENOMEM;
-	memcpy(fifo_buffer, buf, len);
 	kfifo_in(&test->up_fifo, &fifo_buffer, 4);
 	wake_up_interruptible(&priv->test.readq);
 
-- 
2.7.0



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

* Re: [PATCH net-next] ieee802154: Use kmemdup instead of duplicating it in ca8210_test_int_driver_write
  2018-08-09  6:44 ` YueHaibing
  (?)
@ 2018-08-09  8:13 ` Stefan Schmidt
  2018-08-09  8:44     ` YueHaibing
  -1 siblings, 1 reply; 7+ messages in thread
From: Stefan Schmidt @ 2018-08-09  8:13 UTC (permalink / raw)
  To: YueHaibing, davem, h.morris, alex.aring; +Cc: linux-kernel, netdev, linux-wpan

Hello.

On 08/09/2018 08:44 AM, YueHaibing wrote:
> Replace calls to kmalloc followed by a memcpy with a direct call to
> kmemdup.
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Is Yue your forname and Haibing your surname? In that case having it
written as

Yue Haibing <yuehaibing@huawei.com>

in the from line as well as in the SOB would be better.

> ---
>  drivers/net/ieee802154/ca8210.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
> index 58299fb..e21279d 100644
> --- a/drivers/net/ieee802154/ca8210.c
> +++ b/drivers/net/ieee802154/ca8210.c
> @@ -634,10 +634,9 @@ static int ca8210_test_int_driver_write(
>  	for (i = 0; i < len; i++)
>  		dev_dbg(&priv->spi->dev, "%#03x\n", buf[i]);
>  
> -	fifo_buffer = kmalloc(len, GFP_KERNEL);
> +	fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
>  	if (!fifo_buffer)
>  		return -ENOMEM;
> -	memcpy(fifo_buffer, buf, len);
>  	kfifo_in(&test->up_fifo, &fifo_buffer, 4);
>  	wake_up_interruptible(&priv->test.readq);

Is this some kernel tree wide change you are submitting patches for or
only for the ca8210 driver? Is there any specific problem you see with
the kmalloc and memcpy code here? To me it looks fine.

The reason I ask is to understand if this is bug fix or a cleanup.

Harry, if you are ok with this one let me know with an Acked-By

regards
Stefan Schmidt

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

* Re: [PATCH net-next] ieee802154: Use kmemdup instead of duplicating it in ca8210_test_int_driver_write
  2018-08-09  8:13 ` Stefan Schmidt
@ 2018-08-09  8:44     ` YueHaibing
  0 siblings, 0 replies; 7+ messages in thread
From: YueHaibing @ 2018-08-09  8:44 UTC (permalink / raw)
  To: Stefan Schmidt, davem, h.morris, alex.aring
  Cc: linux-kernel, netdev, linux-wpan

On 2018/8/9 16:13, Stefan Schmidt wrote:
> Hello.
> 
> On 08/09/2018 08:44 AM, YueHaibing wrote:
>> Replace calls to kmalloc followed by a memcpy with a direct call to
>> kmemdup.
>>
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> 
> Is Yue your forname and Haibing your surname? In that case having it
> written as
> 
> Yue Haibing <yuehaibing@huawei.com>

Well, It should be this, but it's been a long time to use the former

> 
> in the from line as well as in the SOB would be better.
> 
>> ---
>>  drivers/net/ieee802154/ca8210.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
>> index 58299fb..e21279d 100644
>> --- a/drivers/net/ieee802154/ca8210.c
>> +++ b/drivers/net/ieee802154/ca8210.c
>> @@ -634,10 +634,9 @@ static int ca8210_test_int_driver_write(
>>  	for (i = 0; i < len; i++)
>>  		dev_dbg(&priv->spi->dev, "%#03x\n", buf[i]);
>>  
>> -	fifo_buffer = kmalloc(len, GFP_KERNEL);
>> +	fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
>>  	if (!fifo_buffer)
>>  		return -ENOMEM;
>> -	memcpy(fifo_buffer, buf, len);
>>  	kfifo_in(&test->up_fifo, &fifo_buffer, 4);
>>  	wake_up_interruptible(&priv->test.readq);
> 
> Is this some kernel tree wide change you are submitting patches for or
> only for the ca8210 driver? Is there any specific problem you see with
> the kmalloc and memcpy code here? To me it looks fine.
> 
> The reason I ask is to understand if this is bug fix or a cleanup.

It just a code cleanup only for ca8210.

> 
> Harry, if you are ok with this one let me know with an Acked-By
> 
> regards
> Stefan Schmidt
> 
> .
> 


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

* Re: [PATCH net-next] ieee802154: Use kmemdup instead of duplicating it in ca8210_test_int_driver_write
@ 2018-08-09  8:44     ` YueHaibing
  0 siblings, 0 replies; 7+ messages in thread
From: YueHaibing @ 2018-08-09  8:44 UTC (permalink / raw)
  To: Stefan Schmidt, davem, h.morris, alex.aring
  Cc: linux-kernel, netdev, linux-wpan

On 2018/8/9 16:13, Stefan Schmidt wrote:
> Hello.
> 
> On 08/09/2018 08:44 AM, YueHaibing wrote:
>> Replace calls to kmalloc followed by a memcpy with a direct call to
>> kmemdup.
>>
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> 
> Is Yue your forname and Haibing your surname? In that case having it
> written as
> 
> Yue Haibing <yuehaibing@huawei.com>

Well, It should be this, but it's been a long time to use the former

> 
> in the from line as well as in the SOB would be better.
> 
>> ---
>>  drivers/net/ieee802154/ca8210.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
>> index 58299fb..e21279d 100644
>> --- a/drivers/net/ieee802154/ca8210.c
>> +++ b/drivers/net/ieee802154/ca8210.c
>> @@ -634,10 +634,9 @@ static int ca8210_test_int_driver_write(
>>  	for (i = 0; i < len; i++)
>>  		dev_dbg(&priv->spi->dev, "%#03x\n", buf[i]);
>>  
>> -	fifo_buffer = kmalloc(len, GFP_KERNEL);
>> +	fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
>>  	if (!fifo_buffer)
>>  		return -ENOMEM;
>> -	memcpy(fifo_buffer, buf, len);
>>  	kfifo_in(&test->up_fifo, &fifo_buffer, 4);
>>  	wake_up_interruptible(&priv->test.readq);
> 
> Is this some kernel tree wide change you are submitting patches for or
> only for the ca8210 driver? Is there any specific problem you see with
> the kmalloc and memcpy code here? To me it looks fine.
> 
> The reason I ask is to understand if this is bug fix or a cleanup.

It just a code cleanup only for ca8210.

> 
> Harry, if you are ok with this one let me know with an Acked-By
> 
> regards
> Stefan Schmidt
> 
> .
> 


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

* Re: [PATCH net-next] ieee802154: Use kmemdup instead of duplicating it in ca8210_test_int_driver_write
  2018-08-09  8:44     ` YueHaibing
  (?)
@ 2018-08-09  8:57     ` Stefan Schmidt
  -1 siblings, 0 replies; 7+ messages in thread
From: Stefan Schmidt @ 2018-08-09  8:57 UTC (permalink / raw)
  To: YueHaibing, davem, h.morris, alex.aring; +Cc: linux-kernel, netdev, linux-wpan

Hello Yue.

On 08/09/2018 10:44 AM, YueHaibing wrote:
> On 2018/8/9 16:13, Stefan Schmidt wrote:
>> Hello.
>>
>> On 08/09/2018 08:44 AM, YueHaibing wrote:
>>> Replace calls to kmalloc followed by a memcpy with a direct call to
>>> kmemdup.
>>>
>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>
>> Is Yue your forname and Haibing your surname? In that case having it
>> written as
>>
>> Yue Haibing <yuehaibing@huawei.com>
> 
> Well, It should be this, but it's been a long time to use the former

Never to late to fix something I guess. :-)
Not blocking this patch base on this though.

>> in the from line as well as in the SOB would be better.
>>
>>> ---
>>>  drivers/net/ieee802154/ca8210.c | 3 +--
>>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
>>> index 58299fb..e21279d 100644
>>> --- a/drivers/net/ieee802154/ca8210.c
>>> +++ b/drivers/net/ieee802154/ca8210.c
>>> @@ -634,10 +634,9 @@ static int ca8210_test_int_driver_write(
>>>  	for (i = 0; i < len; i++)
>>>  		dev_dbg(&priv->spi->dev, "%#03x\n", buf[i]);
>>>  
>>> -	fifo_buffer = kmalloc(len, GFP_KERNEL);
>>> +	fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
>>>  	if (!fifo_buffer)
>>>  		return -ENOMEM;
>>> -	memcpy(fifo_buffer, buf, len);
>>>  	kfifo_in(&test->up_fifo, &fifo_buffer, 4);
>>>  	wake_up_interruptible(&priv->test.readq);
>>
>> Is this some kernel tree wide change you are submitting patches for or
>> only for the ca8210 driver? Is there any specific problem you see with
>> the kmalloc and memcpy code here? To me it looks fine.
>>
>> The reason I ask is to understand if this is bug fix or a cleanup.
> 
> It just a code cleanup only for ca8210.

Thanks for the info. I will wait for Harry's ack and apply it to
wpan-next afterwards.

regards
Stefan Schmidt

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

* Re: [PATCH net-next] ieee802154: Use kmemdup instead of duplicating it in ca8210_test_int_driver_write
  2018-08-09  6:44 ` YueHaibing
  (?)
  (?)
@ 2018-08-23  8:31 ` Stefan Schmidt
  -1 siblings, 0 replies; 7+ messages in thread
From: Stefan Schmidt @ 2018-08-23  8:31 UTC (permalink / raw)
  To: YueHaibing, davem, h.morris, alex.aring; +Cc: linux-kernel, netdev, linux-wpan

Hello.

On 08/09/2018 08:44 AM, YueHaibing wrote:
> Replace calls to kmalloc followed by a memcpy with a direct call to
> kmemdup.
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/net/ieee802154/ca8210.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
> index 58299fb..e21279d 100644
> --- a/drivers/net/ieee802154/ca8210.c
> +++ b/drivers/net/ieee802154/ca8210.c
> @@ -634,10 +634,9 @@ static int ca8210_test_int_driver_write(
>  	for (i = 0; i < len; i++)
>  		dev_dbg(&priv->spi->dev, "%#03x\n", buf[i]);
>  
> -	fifo_buffer = kmalloc(len, GFP_KERNEL);
> +	fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
>  	if (!fifo_buffer)
>  		return -ENOMEM;
> -	memcpy(fifo_buffer, buf, len);
>  	kfifo_in(&test->up_fifo, &fifo_buffer, 4);
>  	wake_up_interruptible(&priv->test.readq);
>  


This patch has been applied to the wpan tree and will be
part of the next pull request to net. Thanks!

regards
Stefan Schmidt

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

end of thread, other threads:[~2018-08-23  8:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-09  6:44 [PATCH net-next] ieee802154: Use kmemdup instead of duplicating it in ca8210_test_int_driver_write YueHaibing
2018-08-09  6:44 ` YueHaibing
2018-08-09  8:13 ` Stefan Schmidt
2018-08-09  8:44   ` YueHaibing
2018-08-09  8:44     ` YueHaibing
2018-08-09  8:57     ` Stefan Schmidt
2018-08-23  8:31 ` Stefan Schmidt

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.