提交 f1fd9d0b 编写于 作者: M Martin Schiller 提交者: Greg Kroah-Hartman

leds: trigger: netdev: fix handling on interface rename

[ Upstream commit 5f820ed52371b4f5d8c43c93f03408d0dbc01e5b ]

The NETDEV_CHANGENAME code is not "unneeded" like it is stated in commit
4cb6560514fa ("leds: trigger: netdev: fix refcnt leak on interface
rename").

The event was accidentally misinterpreted equivalent to
NETDEV_UNREGISTER, but should be equivalent to NETDEV_REGISTER.

This was the case in the original code from the openwrt project.

Otherwise, you are unable to set netdev led triggers for (non-existent)
netdevices, which has to be renamed. This is the case, for example, for
ppp interfaces in openwrt.

Fixes: 06f502f5 ("leds: trigger: Introduce a NETDEV trigger")
Fixes: 4cb6560514fa ("leds: trigger: netdev: fix refcnt leak on interface rename")
Signed-off-by: NMartin Schiller <ms@dev.tdt.de>
Signed-off-by: NPavel Machek <pavel@ucw.cz>
Signed-off-by: NSasha Levin <sashal@kernel.org>
上级 935f3980
...@@ -302,10 +302,12 @@ static int netdev_trig_notify(struct notifier_block *nb, ...@@ -302,10 +302,12 @@ static int netdev_trig_notify(struct notifier_block *nb,
container_of(nb, struct led_netdev_data, notifier); container_of(nb, struct led_netdev_data, notifier);
if (evt != NETDEV_UP && evt != NETDEV_DOWN && evt != NETDEV_CHANGE if (evt != NETDEV_UP && evt != NETDEV_DOWN && evt != NETDEV_CHANGE
&& evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER) && evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER
&& evt != NETDEV_CHANGENAME)
return NOTIFY_DONE; return NOTIFY_DONE;
if (!(dev == trigger_data->net_dev || if (!(dev == trigger_data->net_dev ||
(evt == NETDEV_CHANGENAME && !strcmp(dev->name, trigger_data->device_name)) ||
(evt == NETDEV_REGISTER && !strcmp(dev->name, trigger_data->device_name)))) (evt == NETDEV_REGISTER && !strcmp(dev->name, trigger_data->device_name))))
return NOTIFY_DONE; return NOTIFY_DONE;
...@@ -315,6 +317,7 @@ static int netdev_trig_notify(struct notifier_block *nb, ...@@ -315,6 +317,7 @@ static int netdev_trig_notify(struct notifier_block *nb,
clear_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode); clear_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode);
switch (evt) { switch (evt) {
case NETDEV_CHANGENAME:
case NETDEV_REGISTER: case NETDEV_REGISTER:
if (trigger_data->net_dev) if (trigger_data->net_dev)
dev_put(trigger_data->net_dev); dev_put(trigger_data->net_dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册