Skip to content

Commit

Permalink
staging: wilc1000: Fix memleak in wilc_bus_probe
Browse files Browse the repository at this point in the history
When devm_clk_get() returns -EPROBE_DEFER, spi_priv
should be freed just like when wilc_cfg80211_init()
fails.

Fixes: 854d66d ("staging: wilc1000: look for rtc_clk clock in spi mode")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Link: https://lore.kernel.org/r/20200819115426.29852-1-dinghao.liu@zju.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
dinghaoliu authored and gregkh committed Aug 28, 2020
1 parent 39b3666 commit d8eb176
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/wireless/microchip/wilc1000/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ static int wilc_bus_probe(struct spi_device *spi)
wilc->dev_irq_num = spi->irq;

wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc_clk");
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
kfree(spi_priv);
return -EPROBE_DEFER;
else if (!IS_ERR(wilc->rtc_clk))
} else if (!IS_ERR(wilc->rtc_clk))
clk_prepare_enable(wilc->rtc_clk);

return 0;
Expand Down

0 comments on commit d8eb176

Please sign in to comment.