Commit 74099b18b8db0670484e0caeb3425fb29ff3144e

Authored by Kay Sievers
Committed by Greg Kroah-Hartman
1 parent cf6a2eacbc

driver-core: skip uevent generation when nobody is listening

Most network namespaces unlikely have listeners to uevents, and should
benefit from skipping all the string copies.

Cc: Eric Biederman <ebiederm@xmission.com>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 1 changed file with 3 additions and 0 deletions Side-by-side Diff

lib/kobject_uevent.c
... ... @@ -259,6 +259,9 @@
259 259 struct sk_buff *skb;
260 260 size_t len;
261 261  
  262 + if (!netlink_has_listeners(uevent_sock, 1))
  263 + continue;
  264 +
262 265 /* allocate message with the maximum possible size */
263 266 len = strlen(action_string) + strlen(devpath) + 2;
264 267 skb = alloc_skb(len + env->buflen, GFP_KERNEL);