diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-03-20 05:20:17 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-21 14:12:03 -0400 |
commit | 7282326b722995c3fabd4dcd9244182b37500252 (patch) | |
tree | 4ffffcf62da593a467cd4e4f4443068ee4b61b0b | |
parent | f734394d861fe71eafa28d6c28199d9847c5a319 (diff) |
spi: fsl-lib: Fix memory leak of pinfo
of_mpc8xxx_spi_probe() allocates memory for pinfo but the memory is not freed
anywhere. of_mpc8xxx_spi_probe() is called in .probe() and pinfo should be
freed in .remove(), so convert kzalloc to devm_kzalloc to fix the memory leak.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/spi/spi-fsl-lib.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/spi/spi-fsl-lib.c b/drivers/spi/spi-fsl-lib.c index 0b75f26158ab..e5d45fca3551 100644 --- a/drivers/spi/spi-fsl-lib.c +++ b/drivers/spi/spi-fsl-lib.c | |||
@@ -200,7 +200,7 @@ int of_mpc8xxx_spi_probe(struct platform_device *ofdev) | |||
200 | const void *prop; | 200 | const void *prop; |
201 | int ret = -ENOMEM; | 201 | int ret = -ENOMEM; |
202 | 202 | ||
203 | pinfo = kzalloc(sizeof(*pinfo), GFP_KERNEL); | 203 | pinfo = devm_kzalloc(&ofdev->dev, sizeof(*pinfo), GFP_KERNEL); |
204 | if (!pinfo) | 204 | if (!pinfo) |
205 | return -ENOMEM; | 205 | return -ENOMEM; |
206 | 206 | ||
@@ -215,15 +215,13 @@ int of_mpc8xxx_spi_probe(struct platform_device *ofdev) | |||
215 | pdata->sysclk = get_brgfreq(); | 215 | pdata->sysclk = get_brgfreq(); |
216 | if (pdata->sysclk == -1) { | 216 | if (pdata->sysclk == -1) { |
217 | pdata->sysclk = fsl_get_sys_freq(); | 217 | pdata->sysclk = fsl_get_sys_freq(); |
218 | if (pdata->sysclk == -1) { | 218 | if (pdata->sysclk == -1) |
219 | ret = -ENODEV; | 219 | return -ENODEV; |
220 | goto err; | ||
221 | } | ||
222 | } | 220 | } |
223 | #else | 221 | #else |
224 | ret = of_property_read_u32(np, "clock-frequency", &pdata->sysclk); | 222 | ret = of_property_read_u32(np, "clock-frequency", &pdata->sysclk); |
225 | if (ret) | 223 | if (ret) |
226 | goto err; | 224 | return ret; |
227 | #endif | 225 | #endif |
228 | 226 | ||
229 | prop = of_get_property(np, "mode", NULL); | 227 | prop = of_get_property(np, "mode", NULL); |
@@ -237,8 +235,4 @@ int of_mpc8xxx_spi_probe(struct platform_device *ofdev) | |||
237 | pdata->flags = SPI_CPM_MODE | SPI_CPM1; | 235 | pdata->flags = SPI_CPM_MODE | SPI_CPM1; |
238 | 236 | ||
239 | return 0; | 237 | return 0; |
240 | |||
241 | err: | ||
242 | kfree(pinfo); | ||
243 | return ret; | ||
244 | } | 238 | } |