From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Julia Lawall <julia@diku.dk>, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 07/38] driver core: module.c: Use kasprintf
Date: Fri, 21 May 2010 09:53:37 -0700 [thread overview]
Message-ID: <1274460848-11377-7-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20100521165106.GA11216@kroah.com>
From: Julia Lawall <julia@diku.dk>
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>
---
drivers/base/module.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/drivers/base/module.c b/drivers/base/module.c
index f32f2f9..db930d3 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;
}
--
1.7.0.3
next prev parent reply other threads:[~2010-05-21 17:01 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-21 16:51 [GIT PATCH] driver core patches for .35 Greg KH
2010-05-21 16:53 ` [PATCH 01/38] drivers/base/cpu.c: fix the output from /sys/devices/system/cpu/offline Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 02/38] firmware_class: fix memory leak - free allocated pages Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 03/38] kref: remove kref_set Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 04/38] Driver core: Reduce the level of request_firmware() messages Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 05/38] driver-core: fix potential race condition in drivers/base/dd.c Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 06/38] Driver core: don't initialize wakeup flags Greg Kroah-Hartman
2010-05-21 16:53 ` Greg Kroah-Hartman [this message]
2010-05-21 16:53 ` [PATCH 08/38] devtmpfs: support !CONFIG_TMPFS Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 09/38] platform_bus: allow custom extensions to system PM methods Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 10/38] drivers/base: Convert dev->sem to mutex Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 11/38] lockdep: Add novalidate class for dev->mutex conversion Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 12/38] firmware class: export nowait to userspace Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 13/38] firmware loader: rely on driver core to create class attribute Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 14/38] firmware loader: split out builtin firmware handling Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 15/38] firmware loader: do not allocate firmare id separately Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 16/38] Driver core: Protect device shutdown from hot unplug events Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 17/38] generate "change" uevent for loop device Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 18/38] sysfs: Basic support for multiple super blocks Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 19/38] sysfs: Remove double free sysfs_get_sb Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 20/38] kobj: Add basic infrastructure for dealing with namespaces Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 21/38] sysfs: Implement sysfs tagged directory support Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 22/38] sysfs: Add support for tagged directories with untagged members Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 23/38] sysfs: Implement sysfs_delete_link Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 24/38] driver core: Implement ns directory support for device classes Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 25/38] sysfs: Comment sysfs directory tagging logic Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 26/38] sysfs-namespaces: add a high-level Documentation file Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 27/38] sysfs: Don't use enums in inline function declaration Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 28/38] sysfs: Remove usage of S_BIAS to avoid merge conflict with the vfs tree Greg Kroah-Hartman
2010-05-21 16:53 ` [PATCH 29/38] sysfs: add struct file* to bin_attr callbacks Greg Kroah-Hartman
2010-05-21 16:54 ` [PATCH 30/38] pci: check caps from sysfs file open to read device dependent config space Greg Kroah-Hartman
2010-05-21 16:54 ` [PATCH 31/38] driver-core: fix Typo in drivers/base/core.c for CONFIG_MODULE Greg Kroah-Hartman
2010-05-21 16:54 ` [PATCH 32/38] kobject: Send hotplug events in all network namespaces Greg Kroah-Hartman
2010-05-21 16:54 ` [PATCH 33/38] netns: Teach network device kobjects which namespace they are in Greg Kroah-Hartman
2010-05-21 16:54 ` [PATCH 34/38] net/sysfs: Fix the bitrot in network device kobject namespace support Greg Kroah-Hartman
2010-05-21 16:54 ` [PATCH 35/38] netlink: Implment netlink_broadcast_filtered Greg Kroah-Hartman
2010-05-21 16:54 ` [PATCH 36/38] kobj: Send hotplug events in the proper namespace Greg Kroah-Hartman
2010-05-21 16:54 ` [PATCH 37/38] hotplug: netns aware uevent_helper Greg Kroah-Hartman
2010-05-21 16:54 ` [PATCH 38/38] net: Expose all network devices in a namespaces in sysfs Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1274460848-11377-7-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=julia@diku.dk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox