From: Geliang Tang Date: Thu, 1 Oct 2015 16:37:57 +0000 (+0800) Subject: pcmcia: use kstrdup() in pcmcia_device_query() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7c22e645cd742b82ec232e4f2328fc53d247ccea;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git pcmcia: use kstrdup() in pcmcia_device_query() Use kstrdup instead of kmalloc and strncpy. Signed-off-by: Geliang Tang Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 0decee6c556e..489ea1098c96 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -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);