402-leds-trigger-netdev-fix-handling-on-interface-rename.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From 0ff035231edca3713c3d0839c44e64a4ac41ef38 Mon Sep 17 00:00:00 2001
  2. From: Martin Schiller <ms@dev.tdt.de>
  3. Date: Thu, 24 Oct 2019 15:09:23 +0200
  4. Subject: [PATCH] leds: trigger: netdev: fix handling on interface rename
  5. The NETDEV_CHANGENAME code is not "unneeded" like it is stated in commit
  6. 4cb6560514fa ("leds: trigger: netdev: fix refcnt leak on interface
  7. rename").
  8. The event was accidentally misinterpreted equivalent to
  9. NETDEV_UNREGISTER, but should be equivalent to NETDEV_REGISTER.
  10. This was the case in the original code from the openwrt project.
  11. Otherwise, you are unable to set netdev led triggers for (non-existent)
  12. netdevices, which has to be renamed. This is the case, for example, for
  13. ppp interfaces in openwrt.
  14. Fixes: 06f502f57d0d ("leds: trigger: Introduce a NETDEV trigger")
  15. Fixes: 4cb6560514fa ("leds: trigger: netdev: fix refcnt leak on interface rename")
  16. Signed-off-by: Martin Schiller <ms@dev.tdt.de>
  17. ---
  18. drivers/leds/trigger/ledtrig-netdev.c | 5 ++++-
  19. 1 file changed, 4 insertions(+), 1 deletion(-)
  20. --- a/drivers/leds/trigger/ledtrig-netdev.c
  21. +++ b/drivers/leds/trigger/ledtrig-netdev.c
  22. @@ -299,10 +299,12 @@ static int netdev_trig_notify(struct not
  23. notifier);
  24. if (evt != NETDEV_UP && evt != NETDEV_DOWN && evt != NETDEV_CHANGE
  25. - && evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER)
  26. + && evt != NETDEV_REGISTER && evt != NETDEV_UNREGISTER
  27. + && evt != NETDEV_CHANGENAME)
  28. return NOTIFY_DONE;
  29. if (!(dev == trigger_data->net_dev ||
  30. + (evt == NETDEV_CHANGENAME && !strcmp(dev->name, trigger_data->device_name)) ||
  31. (evt == NETDEV_REGISTER && !strcmp(dev->name, trigger_data->device_name))))
  32. return NOTIFY_DONE;
  33. @@ -312,6 +314,7 @@ static int netdev_trig_notify(struct not
  34. clear_bit(NETDEV_LED_MODE_LINKUP, &trigger_data->mode);
  35. switch (evt) {
  36. + case NETDEV_CHANGENAME:
  37. case NETDEV_REGISTER:
  38. if (trigger_data->net_dev)
  39. dev_put(trigger_data->net_dev);