public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: change to use kmalloc
@ 2015-11-11  4:23 yalin wang
  2015-11-11 17:02 ` Alim Akhtar
  0 siblings, 1 reply; 5+ messages in thread
From: yalin wang @ 2015-11-11  4:23 UTC (permalink / raw)
  To: ulf.hansson, adrian.hunter, ben, jh80.chung, asaf.vertz, tklauser,
	jonathanh, JBottomley, grundler, linux-mmc, linux-kernel
  Cc: yalin wang

Use kmalloc instead of kzalloc, zero the memory is not needed.

Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
---
 drivers/mmc/card/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 23b6c8e..975cd3e 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -365,7 +365,7 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
 	if (!idata->buf_bytes)
 		return idata;
 
-	idata->buf = kzalloc(idata->buf_bytes, GFP_KERNEL);
+	idata->buf = kmalloc(idata->buf_bytes, GFP_KERNEL);
 	if (!idata->buf) {
 		err = -ENOMEM;
 		goto idata_err;
-- 
1.9.1


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

* Re: [PATCH] mmc: change to use kmalloc
  2015-11-11  4:23 [PATCH] mmc: change to use kmalloc yalin wang
@ 2015-11-11 17:02 ` Alim Akhtar
  2015-11-11 21:17   ` Peter Hurley
  0 siblings, 1 reply; 5+ messages in thread
From: Alim Akhtar @ 2015-11-11 17:02 UTC (permalink / raw)
  To: yalin wang
  Cc: Ulf Hansson, Adrian Hunter, ben, Jaehoon Chung, asaf.vertz,
	tklauser, jonathanh, James E.J. Bottomley, Grant Grundler,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org

Hi Yalin,

On Wed, Nov 11, 2015 at 9:53 AM, yalin wang <yalin.wang2010@gmail.com> wrote:
> Use kmalloc instead of kzalloc, zero the memory is not needed.
>
why you want to do this? what problem you faces, and how this resolves the same?

> Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
> ---
>  drivers/mmc/card/block.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 23b6c8e..975cd3e 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -365,7 +365,7 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
>         if (!idata->buf_bytes)
>                 return idata;
>
> -       idata->buf = kzalloc(idata->buf_bytes, GFP_KERNEL);
> +       idata->buf = kmalloc(idata->buf_bytes, GFP_KERNEL);
>         if (!idata->buf) {
>                 err = -ENOMEM;
>                 goto idata_err;
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Regards,
Alim

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

* Re: [PATCH] mmc: change to use kmalloc
  2015-11-11 17:02 ` Alim Akhtar
@ 2015-11-11 21:17   ` Peter Hurley
  2015-11-11 21:57     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Hurley @ 2015-11-11 21:17 UTC (permalink / raw)
  To: Alim Akhtar, yalin wang
  Cc: Ulf Hansson, Adrian Hunter, ben, Jaehoon Chung, asaf.vertz,
	tklauser, jonathanh, James E.J. Bottomley, Grant Grundler,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org

On 11/11/2015 12:02 PM, Alim Akhtar wrote:
> Hi Yalin,
> 
> On Wed, Nov 11, 2015 at 9:53 AM, yalin wang <yalin.wang2010@gmail.com> wrote:
>> Use kmalloc instead of kzalloc, zero the memory is not needed.
>>
> why you want to do this? what problem you faces, and how this resolves the same?

The patch fixes an inefficiency: explicitly zeroing memory that is then
immediately overwritten 6 lines below is wasteful.

Regards,
Peter Hurley

>> Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
>> ---
>>  drivers/mmc/card/block.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> index 23b6c8e..975cd3e 100644
>> --- a/drivers/mmc/card/block.c
>> +++ b/drivers/mmc/card/block.c
>> @@ -365,7 +365,7 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
>>         if (!idata->buf_bytes)
>>                 return idata;
>>
>> -       idata->buf = kzalloc(idata->buf_bytes, GFP_KERNEL);
>> +       idata->buf = kmalloc(idata->buf_bytes, GFP_KERNEL);
>>         if (!idata->buf) {
>>                 err = -ENOMEM;
>>                 goto idata_err;
>> --
>> 1.9.1


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

* Re: [PATCH] mmc: change to use kmalloc
  2015-11-11 21:17   ` Peter Hurley
@ 2015-11-11 21:57     ` Andy Shevchenko
  2015-11-12 11:27       ` yalin wang
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2015-11-11 21:57 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Alim Akhtar, yalin wang, Ulf Hansson, Adrian Hunter,
	Ben Hutchings, Jaehoon Chung, asaf.vertz, tklauser, Jon Hunter,
	James E.J. Bottomley, Grant Grundler, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Wed, Nov 11, 2015 at 11:17 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
> On 11/11/2015 12:02 PM, Alim Akhtar wrote:
>> Hi Yalin,
>>
>> On Wed, Nov 11, 2015 at 9:53 AM, yalin wang <yalin.wang2010@gmail.com> wrote:
>>> Use kmalloc instead of kzalloc, zero the memory is not needed.
>>>
>> why you want to do this? what problem you faces, and how this resolves the same?
>
> The patch fixes an inefficiency: explicitly zeroing memory that is then
> immediately overwritten 6 lines below is wasteful.

It might fix previous kzalloc as well, though better not to do since
it's error prone.

>
> Regards,
> Peter Hurley
>
>>> Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
>>> ---
>>>  drivers/mmc/card/block.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>>> index 23b6c8e..975cd3e 100644
>>> --- a/drivers/mmc/card/block.c
>>> +++ b/drivers/mmc/card/block.c
>>> @@ -365,7 +365,7 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
>>>         if (!idata->buf_bytes)
>>>                 return idata;
>>>
>>> -       idata->buf = kzalloc(idata->buf_bytes, GFP_KERNEL);
>>> +       idata->buf = kmalloc(idata->buf_bytes, GFP_KERNEL);
>>>         if (!idata->buf) {
>>>                 err = -ENOMEM;
>>>                 goto idata_err;
>>> --
>>> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] mmc: change to use kmalloc
  2015-11-11 21:57     ` Andy Shevchenko
@ 2015-11-12 11:27       ` yalin wang
  0 siblings, 0 replies; 5+ messages in thread
From: yalin wang @ 2015-11-12 11:27 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Peter Hurley, Alim Akhtar, Ulf Hansson, Adrian Hunter,
	Ben Hutchings, Jaehoon Chung, asaf.vertz, Tobias Klauser,
	Jon Hunter, James E.J. Bottomley, Grant Grundler,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org


> On Nov 12, 2015, at 05:57, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> 
> On Wed, Nov 11, 2015 at 11:17 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
>> On 11/11/2015 12:02 PM, Alim Akhtar wrote:
>>> Hi Yalin,
>>> 
>>> On Wed, Nov 11, 2015 at 9:53 AM, yalin wang <yalin.wang2010@gmail.com> wrote:
>>>> Use kmalloc instead of kzalloc, zero the memory is not needed.
>>>> 
>>> why you want to do this? what problem you faces, and how this resolves the same?
>> 
>> The patch fixes an inefficiency: explicitly zeroing memory that is then
>> immediately overwritten 6 lines below is wasteful.
> 
> It might fix previous kzalloc as well, though better not to do since
> it's error prone.
> 
yeah,  i will send a new patch ,



>> 
>> Regards,
>> Peter Hurley
>> 
>>>> Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
>>>> ---
>>>> drivers/mmc/card/block.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>> 
>>>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>>>> index 23b6c8e..975cd3e 100644
>>>> --- a/drivers/mmc/card/block.c
>>>> +++ b/drivers/mmc/card/block.c
>>>> @@ -365,7 +365,7 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
>>>>        if (!idata->buf_bytes)
>>>>                return idata;
>>>> 
>>>> -       idata->buf = kzalloc(idata->buf_bytes, GFP_KERNEL);
>>>> +       idata->buf = kmalloc(idata->buf_bytes, GFP_KERNEL);
>>>>        if (!idata->buf) {
>>>>                err = -ENOMEM;
>>>>                goto idata_err;
>>>> --
>>>> 1.9.1
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 
> 
> -- 
> With Best Regards,
> Andy Shevchenko


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

end of thread, other threads:[~2015-11-12 11:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-11  4:23 [PATCH] mmc: change to use kmalloc yalin wang
2015-11-11 17:02 ` Alim Akhtar
2015-11-11 21:17   ` Peter Hurley
2015-11-11 21:57     ` Andy Shevchenko
2015-11-12 11:27       ` yalin wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox