Skip to content

Commit e361560

Browse files
q2venkuba-moo
authored andcommitted
dev: Acquire netdev_rename_lock before restoring dev->name in dev_change_name().
The cited commit forgot to add netdev_rename_lock in one of the error paths in dev_change_name(). Let's hold netdev_rename_lock before restoring the old dev->name. Fixes: 0840556 ("net: Protect dev->name by seqlock.") Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8d20dcd commit e361560

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/core/dev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,9 @@ int dev_change_name(struct net_device *dev, const char *newname)
13891389
rollback:
13901390
ret = device_rename(&dev->dev, dev->name);
13911391
if (ret) {
1392+
write_seqlock_bh(&netdev_rename_lock);
13921393
memcpy(dev->name, oldname, IFNAMSIZ);
1394+
write_sequnlock_bh(&netdev_rename_lock);
13931395
WRITE_ONCE(dev->name_assign_type, old_assign_type);
13941396
up_write(&devnet_rename_sem);
13951397
return ret;

0 commit comments

Comments
 (0)