From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benoit Taine Date: Mon, 26 May 2014 15:21:12 +0000 Subject: [PATCH 2/18] memstick: Use kmemdup instead of kmalloc + memcpy Message-Id: <1401117687-28911-4-git-send-email-benoit.taine@lip6.fr> List-Id: References: <1401117687-28911-1-git-send-email-benoit.taine@lip6.fr> In-Reply-To: <1401117687-28911-1-git-send-email-benoit.taine@lip6.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-kernel@vger.kernel.org Cc: benoit.taine@lip6.fr, kernel-janitors@vger.kernel.org This issue was reported by coccicheck using the semantic patch at scripts/coccinelle/api/memdup.cocci Signed-off-by: Benoit Taine --- Tested by compilation without errors. drivers/memstick/core/mspro_block.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index fc145d2..d52412d 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c @@ -1032,12 +1032,11 @@ static int mspro_block_read_attributes(struct memstick_dev *card) } msb->attr_group.name = "media_attributes"; - buffer = kmalloc(attr_len, GFP_KERNEL); + buffer = kmemdup((char *)attr, attr_len, GFP_KERNEL); if (!buffer) { rc = -ENOMEM; goto out_free_attr; } - memcpy(buffer, (char *)attr, attr_len); for (cnt = 0; cnt < attr_count; ++cnt) { s_attr = kzalloc(sizeof(struct mspro_sys_attr), GFP_KERNEL);