summaryrefslogtreecommitdiffstats
path: root/drivers/base/module.c
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2010-03-10 22:18:13 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-21 18:37:29 +0200
commit1653268b1b538981df9bb85d637456530938be6c (patch)
treef091543b753e57e975bee35909b96c674daf3bd3 /drivers/base/module.c
parentDriver core: don't initialize wakeup flags (diff)
downloadlinux-1653268b1b538981df9bb85d637456530938be6c.tar.xz
linux-1653268b1b538981df9bb85d637456530938be6c.zip
driver core: module.c: Use kasprintf
kasprintf combines kmalloc and sprintf, and takes care of the size calculation itself. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression a,flag; expression list args; statement S; @@ a = - \(kmalloc\|kzalloc\)(...,flag) + kasprintf(flag,args) <... when != a if (a == NULL || ...) S ...> - sprintf(a,args); // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/module.c')
-rw-r--r--drivers/base/module.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/base/module.c b/drivers/base/module.c
index f32f2f9b7be5..db930d3ee312 100644
--- a/drivers/base/module.c
+++ b/drivers/base/module.c
@@ -15,12 +15,10 @@ static char *make_driver_name(struct device_driver *drv)
{
char *driver_name;
- driver_name = kmalloc(strlen(drv->name) + strlen(drv->bus->name) + 2,
- GFP_KERNEL);
+ driver_name = kasprintf(GFP_KERNEL, "%s:%s", drv->bus->name, drv->name);
if (!driver_name)
return NULL;
- sprintf(driver_name, "%s:%s", drv->bus->name, drv->name);
return driver_name;
}