Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1266961 > unrolled thread

[PATCH] mmc: change to use kmalloc

Started byyalin wang <yalin.wang2010@gmail.com>
First post2015-11-11 05:30 +0100
Last post2015-11-12 12:30 +0100
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mmc: change to use kmalloc yalin wang <yalin.wang2010@gmail.com> - 2015-11-11 05:30 +0100
    Re: [PATCH] mmc: change to use kmalloc Alim Akhtar <alim.akhtar@gmail.com> - 2015-11-11 18:10 +0100
      Re: [PATCH] mmc: change to use kmalloc Peter Hurley <peter@hurleysoftware.com> - 2015-11-11 22:20 +0100
        Re: [PATCH] mmc: change to use kmalloc Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-11-11 23:00 +0100
          Re: [PATCH] mmc: change to use kmalloc yalin wang <yalin.wang2010@gmail.com> - 2015-11-12 12:30 +0100

#1266961 — [PATCH] mmc: change to use kmalloc

Fromyalin wang <yalin.wang2010@gmail.com>
Date2015-11-11 05:30 +0100
Subject[PATCH] mmc: change to use kmalloc
Message-ID<qtvcJ-6jz-1@gated-at.bofh.it>
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

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

[toc] | [next] | [standalone]


#1267331

FromAlim Akhtar <alim.akhtar@gmail.com>
Date2015-11-11 18:10 +0100
Message-ID<qtH4d-5Cm-7@gated-at.bofh.it>
In reply to#1266961
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
--
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/

[toc] | [prev] | [next] | [standalone]


#1267452

FromPeter Hurley <peter@hurleysoftware.com>
Date2015-11-11 22:20 +0100
Message-ID<qtKY9-88r-13@gated-at.bofh.it>
In reply to#1267331
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

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

[toc] | [prev] | [next] | [standalone]


#1267466

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2015-11-11 23:00 +0100
Message-ID<qtLAR-8mQ-5@gated-at.bofh.it>
In reply to#1267452
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
--
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/

[toc] | [prev] | [next] | [standalone]


#1267832

Fromyalin wang <yalin.wang2010@gmail.com>
Date2015-11-12 12:30 +0100
Message-ID<qtYeK-8ek-17@gated-at.bofh.it>
In reply to#1267466
> 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

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web