Skip to content

Commit

Permalink
fixup dsa_switchdev_event_work with dev_put
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
  • Loading branch information
vladimiroltean committed Jul 22, 2020
1 parent 9159728 commit 8ed3f46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions net/dsa/dsa_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct dsa_notifier_mtu_info {
};

struct dsa_switchdev_event_work {
struct net_device *dev; /* for dev_hold and dev_put only */
struct dsa_switch *ds;
int port;
struct work_struct work;
Expand Down
5 changes: 3 additions & 2 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ static int dsa_upstream_fdb_addr(struct net_device *slave_dev,
return -ENOMEM;

INIT_WORK(&switchdev_work->work, dsa_slave_switchdev_event_work);
switchdev_work->dev = slave_dev;
switchdev_work->ds = dp->ds;
switchdev_work->port = dsa_upstream_port(dp->ds, dp->index);
switchdev_work->event = event;
Expand Down Expand Up @@ -2149,9 +2150,8 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work)
}
rtnl_unlock();

dev_put(switchdev_work->dev);
kfree(switchdev_work);
if (dsa_is_user_port(ds, dp->index))
dev_put(dp->slave);
}

/* Called under rcu_read_lock() */
Expand Down Expand Up @@ -2182,6 +2182,7 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused,

INIT_WORK(&switchdev_work->work,
dsa_slave_switchdev_event_work);
switchdev_work->dev = dev;
switchdev_work->ds = dp->ds;
switchdev_work->port = dp->index;
switchdev_work->event = event;
Expand Down

0 comments on commit 8ed3f46

Please sign in to comment.