From: Ben Hutchings Date: Thu, 9 Sep 2010 04:21:16 +0000 (+0100) Subject: tun: Don't add sysfs attributes to devices without sysfs directories X-Git-Tag: firefly_0821_release~10186^2~1018 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=11bb28b4168d940f156b9752e8d12ca403cb0426;p=firefly-linux-kernel-4.4.55.git tun: Don't add sysfs attributes to devices without sysfs directories This applies to 2.6.32 *only*. It has not been applied upstream since the limitation no longer exists. Prior to Linux 2.6.35, net devices outside the initial net namespace did not have sysfs directories. Attempting to add attributes to them will trigger a BUG(). Reported-and-tested-by: Russell Stuart Signed-off-by: Ben Hutchings Acked-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 4fdfa2ae5418..0f77aca7280a 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1006,7 +1006,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) if (err < 0) goto err_free_sk; - if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) || + if (!net_eq(dev_net(tun->dev), &init_net) || + device_create_file(&tun->dev->dev, &dev_attr_tun_flags) || device_create_file(&tun->dev->dev, &dev_attr_owner) || device_create_file(&tun->dev->dev, &dev_attr_group)) printk(KERN_ERR "Failed to create tun sysfs files\n");