summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
Diffstat (limited to 'net/core')
-rw-r--r--net/core/net-sysfs.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index d9b33e923b18..a09d507c5b03 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -193,6 +193,10 @@ static ssize_t carrier_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct net_device *netdev = to_net_dev(dev);
+ int ret = -EINVAL;
+
+ if (!rtnl_trylock())
+ return restart_syscall();
if (netif_running(netdev)) {
/* Synchronize carrier state with link watch,
@@ -200,10 +204,11 @@ static ssize_t carrier_show(struct device *dev,
*/
linkwatch_sync_dev(netdev);
- return sysfs_emit(buf, fmt_dec, !!netif_carrier_ok(netdev));
+ ret = sysfs_emit(buf, fmt_dec, !!netif_carrier_ok(netdev));
}
+ rtnl_unlock();
- return -EINVAL;
+ return ret;
}
static DEVICE_ATTR_RW(carrier);