Skip to content

Commit

Permalink
pcmcia: use kstrdup() in pcmcia_device_query()
Browse files Browse the repository at this point in the history
Use kstrdup instead of kmalloc and strncpy.

Signed-off-by: Geliang Tang <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
geliangtang authored and gregkh committed Oct 5, 2015
1 parent df6be79 commit 7c22e64
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/pcmcia/ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,10 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
if ((length < 2) || (length > 255))
continue;

new = kmalloc(sizeof(char) * length, GFP_KERNEL);
new = kstrdup(tmp, GFP_KERNEL);
if (!new)
continue;

new = strncpy(new, tmp, length);

tmp = p_dev->prod_id[i];
p_dev->prod_id[i] = new;
kfree(tmp);
Expand Down

0 comments on commit 7c22e64

Please sign in to comment.