Skip to content

Commit

Permalink
net: lan78xx: fix runtime PM count underflow on link stop
Browse files Browse the repository at this point in the history
[ Upstream commit 1eecc7a ]

Current driver has some asymmetry in the runtime PM calls. On lan78xx_open()
it will call usb_autopm_get() and unconditionally usb_autopm_put(). And
on lan78xx_stop() it will call only usb_autopm_put(). So far, it was
working only because this driver do not activate autosuspend by default,
so it was visible only by warning "Runtime PM usage count underflow!".

Since, with current driver, we can't use runtime PM with active link,
execute lan78xx_open()->usb_autopm_put() only in error case. Otherwise,
keep ref counting high as long as interface is open.

Fixes: 55d7de9 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
olerem authored and Sasha Levin committed Mar 15, 2024
1 parent 104ecbf commit a382c4a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/usb/lan78xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -3137,7 +3137,8 @@ static int lan78xx_open(struct net_device *net)
done:
mutex_unlock(&dev->dev_mutex);

usb_autopm_put_interface(dev->intf);
if (ret < 0)
usb_autopm_put_interface(dev->intf);

return ret;
}
Expand Down

0 comments on commit a382c4a

Please sign in to comment.