Home Home > GIT Browse > SLE15-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Kubecek <mkubecek@suse.cz>2019-02-14 14:04:18 +0100
committerMichal Kubecek <mkubecek@suse.cz>2019-02-14 14:04:18 +0100
commit5912133fc773d1d0343dac5afc613a2bb575a02f (patch)
treefe40837dfd132b1016797ba3efc458d9ad3a2b1c
parentdf9d7f340dca96322c95553e061080d1b533ddd1 (diff)
kobject: factorize skb setup in kobject_uevent_net_broadcast()
(bsc#1122982). suse-commit: 981380dac20036706dd55ca3ae7741d61dfc7419
-rw-r--r--lib/kobject_uevent.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 3f0e6afee29c..cdde3db2481b 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -158,23 +158,26 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,
{
int retval = 0;
#if defined(CONFIG_NET)
+ struct sk_buff *skb = NULL;
struct uevent_sock *ue_sk;
/* send netlink message */
list_for_each_entry(ue_sk, &uevent_sock_list, list) {
struct sock *uevent_sock = ue_sk->sk;
- 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);
- if (skb) {
+ if (!skb) {
+ /* allocate message with the maximum possible size */
+ size_t len = strlen(action_string) + strlen(devpath) + 2;
char *scratch;
+ retval = -ENOMEM;
+ skb = alloc_skb(len + env->buflen, GFP_KERNEL);
+ if (!skb)
+ continue;
+
/* add header */
scratch = skb_put(skb, len);
sprintf(scratch, "%s@%s", action_string, devpath);
@@ -182,16 +185,17 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,
skb_put_data(skb, env->buf, env->buflen);
NETLINK_CB(skb).dst_group = 1;
- retval = netlink_broadcast_filtered(uevent_sock, skb,
- 0, 1, GFP_KERNEL,
- kobj_bcast_filter,
- kobj);
- /* ENOBUFS should be handled in userspace */
- if (retval == -ENOBUFS || retval == -ESRCH)
- retval = 0;
- } else
- retval = -ENOMEM;
+ }
+
+ retval = netlink_broadcast_filtered(uevent_sock, skb_get(skb),
+ 0, 1, GFP_KERNEL,
+ kobj_bcast_filter,
+ kobj);
+ /* ENOBUFS should be handled in userspace */
+ if (retval == -ENOBUFS || retval == -ESRCH)
+ retval = 0;
}
+ consume_skb(skb);
#endif
return retval;
}