Skip to content

Commit

Permalink
can: xilinx_can: handle failure cases of pm_runtime_get_sync
Browse files Browse the repository at this point in the history
Calling pm_runtime_get_sync increments the counter even in case of
failure, causing incorrect ref count. Call pm_runtime_put if
pm_runtime_get_sync fails.

Signed-off-by: Navid Emamdoost <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Fixes: 4716620 ("can: xilinx: Convert to runtime_pm")
Signed-off-by: Marc Kleine-Budde <[email protected]>
  • Loading branch information
Navidem authored and marckleinebudde committed Nov 3, 2020
1 parent e002103 commit 79c4333
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/can/xilinx_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ static int xcan_open(struct net_device *ndev)
if (ret < 0) {
netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n",
__func__, ret);
return ret;
goto err;
}

ret = request_irq(ndev->irq, xcan_interrupt, priv->irq_flags,
Expand Down Expand Up @@ -1479,6 +1479,7 @@ static int xcan_get_berr_counter(const struct net_device *ndev,
if (ret < 0) {
netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n",
__func__, ret);
pm_runtime_put(priv->dev);
return ret;
}

Expand Down Expand Up @@ -1793,7 +1794,7 @@ static int xcan_probe(struct platform_device *pdev)
if (ret < 0) {
netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n",
__func__, ret);
goto err_pmdisable;
goto err_disableclks;
}

if (priv->read_reg(priv, XCAN_SR_OFFSET) != XCAN_SR_CONFIG_MASK) {
Expand Down Expand Up @@ -1828,7 +1829,6 @@ static int xcan_probe(struct platform_device *pdev)

err_disableclks:
pm_runtime_put(priv->dev);
err_pmdisable:
pm_runtime_disable(&pdev->dev);
err_free:
free_candev(ndev);
Expand Down

0 comments on commit 79c4333

Please sign in to comment.