Skip to contentSkip to conversation

mmc: change to use kmalloc

PATCH Superseded yalin wang 4 participants 5 messages Nov 11, 2015 – Nov 12, 2015 MMC, SD and SDIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

yalin wang

author
#0 lore raw

PATCH 1/1 mmc: change to use kmalloc

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

---
 drivers/mmc/card/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/card/block.c +1 -1
index 23b6c8e..975cd3e 100644
@@ -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;
Signature · 1 line
1.9.1
#1 lore raw

Hi Yalin,

Quoted 2 lines · yalin wang

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?

Quoted 25 lines
---
 drivers/mmc/card/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/card/block.c +1 -2
index 23b6c8e..975cd3e 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Regards,
Alim
#2 lore raw
Quoted 6 lines · Alim Akhtar

Hi Yalin,

Quoted 2 lines · yalin wang

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

Quoted 20 lines
Quoted 20 lines
---
 drivers/mmc/card/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/card/block.c +1 -2
index 23b6c8e..975cd3e 100644
@@ -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

#3 lore raw
Quoted 10 lines · Peter Hurley
Quoted 6 lines · Alim Akhtar

Hi Yalin,

Quoted 2 lines · yalin wang

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.

Quoted 30 lines

Regards,
Peter Hurley

Quoted 13 lines
Quoted 13 lines
---
 drivers/mmc/card/block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/card/block.c +0 -0
index 23b6c8e..975cd3e 100644
@@ -365,7 +365,7 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
        if (!idata->buf_bytes)
                return idata;
 
Quoted 7 lines
Quoted 7 lines
drivers/mmc/card/block.c +1 -2
-       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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#4 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · Peter Hurley
Quoted 5 lines · Alim Akhtar

Hi Yalin,

Quoted 2 lines · yalin wang

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

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

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 ,

Quoted 36 lines
Quoted 30 lines

Regards,
Peter Hurley

Quoted 13 lines
Quoted 13 lines

---
drivers/mmc/card/block.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/card/block.c +0 -0
index 23b6c8e..975cd3e 100644
@@ -365,7 +365,7 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
       if (!idata->buf_bytes)
               return idata;
 
Quoted 7 lines
Quoted 7 lines
drivers/mmc/card/block.c +1 -2
-       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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
With Best Regards,
Andy Shevchenko