From: Kay Sievers Date: Mon, 5 Dec 2011 18:12:47 +0000 (+0100) Subject: driver-core: skip uevent generation when nobody is listening X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=74099b18b8db0670484e0caeb3425fb29ff3144e;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git 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 Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index ad72a03ce5e9..e66e9b632617 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -259,6 +259,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, struct sk_buff *skb; size_t len; + if (!netlink_has_listeners(uevent_sock, 1)) + continue; + /* allocate message with the maximum possible size */ len = strlen(action_string) + strlen(devpath) + 2; skb = alloc_skb(len + env->buflen, GFP_KERNEL);