Commit a968c799 authored by Lu Wei's avatar Lu Wei Committed by Paolo Abeni

ax25: merge repeat codes in ax25_dev_device_down()

Merge repeat codes to reduce the duplication.
Signed-off-by: default avatarLu Wei <luwei32@huawei.com>
Link: https://lore.kernel.org/r/20220516062804.254742-1-luwei32@huawei.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent bcdcf2c4
...@@ -115,23 +115,13 @@ void ax25_dev_device_down(struct net_device *dev) ...@@ -115,23 +115,13 @@ void ax25_dev_device_down(struct net_device *dev)
if ((s = ax25_dev_list) == ax25_dev) { if ((s = ax25_dev_list) == ax25_dev) {
ax25_dev_list = s->next; ax25_dev_list = s->next;
spin_unlock_bh(&ax25_dev_lock); goto unlock_put;
ax25_dev_put(ax25_dev);
dev->ax25_ptr = NULL;
dev_put_track(dev, &ax25_dev->dev_tracker);
ax25_dev_put(ax25_dev);
return;
} }
while (s != NULL && s->next != NULL) { while (s != NULL && s->next != NULL) {
if (s->next == ax25_dev) { if (s->next == ax25_dev) {
s->next = ax25_dev->next; s->next = ax25_dev->next;
spin_unlock_bh(&ax25_dev_lock); goto unlock_put;
ax25_dev_put(ax25_dev);
dev->ax25_ptr = NULL;
dev_put_track(dev, &ax25_dev->dev_tracker);
ax25_dev_put(ax25_dev);
return;
} }
s = s->next; s = s->next;
...@@ -139,6 +129,14 @@ void ax25_dev_device_down(struct net_device *dev) ...@@ -139,6 +129,14 @@ void ax25_dev_device_down(struct net_device *dev)
spin_unlock_bh(&ax25_dev_lock); spin_unlock_bh(&ax25_dev_lock);
dev->ax25_ptr = NULL; dev->ax25_ptr = NULL;
ax25_dev_put(ax25_dev); ax25_dev_put(ax25_dev);
return;
unlock_put:
spin_unlock_bh(&ax25_dev_lock);
ax25_dev_put(ax25_dev);
dev->ax25_ptr = NULL;
dev_put_track(dev, &ax25_dev->dev_tracker);
ax25_dev_put(ax25_dev);
} }
int ax25_fwd_ioctl(unsigned int cmd, struct ax25_fwd_struct *fwd) int ax25_fwd_ioctl(unsigned int cmd, struct ax25_fwd_struct *fwd)
......
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