Commit af7320ec authored by Yang Li's avatar Yang Li Committed by Lee Jones

leds: trigger: netdev: Remove NULL check before dev_{put, hold}

The call netdev_{put, hold} of dev_{put, hold} will check NULL,
so there is no need to check before using dev_{put, hold},
remove it to silence the warnings:

./drivers/leds/trigger/ledtrig-netdev.c:291:3-10: WARNING: NULL check before dev_{put, hold} functions is not needed.
./drivers/leds/trigger/ledtrig-netdev.c:401:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed.
Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=4929Signed-off-by: default avatarYang Li <yang.lee@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230511070820.52731-1-yang.lee@linux.alibaba.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent 82f80ef5
...@@ -287,8 +287,7 @@ static int netdev_trig_notify(struct notifier_block *nb, ...@@ -287,8 +287,7 @@ static int netdev_trig_notify(struct notifier_block *nb,
trigger_data->carrier_link_up = netif_carrier_ok(dev); trigger_data->carrier_link_up = netif_carrier_ok(dev);
fallthrough; fallthrough;
case NETDEV_REGISTER: case NETDEV_REGISTER:
if (trigger_data->net_dev) dev_put(trigger_data->net_dev);
dev_put(trigger_data->net_dev);
dev_hold(dev); dev_hold(dev);
trigger_data->net_dev = dev; trigger_data->net_dev = dev;
break; break;
...@@ -397,8 +396,7 @@ static void netdev_trig_deactivate(struct led_classdev *led_cdev) ...@@ -397,8 +396,7 @@ static void netdev_trig_deactivate(struct led_classdev *led_cdev)
cancel_delayed_work_sync(&trigger_data->work); cancel_delayed_work_sync(&trigger_data->work);
if (trigger_data->net_dev) dev_put(trigger_data->net_dev);
dev_put(trigger_data->net_dev);
kfree(trigger_data); kfree(trigger_data);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment