summaryrefslogtreecommitdiff
path: root/drivers/spi
diff options
context:
space:
mode:
authorChao Fu <B44548@freescale.com>2014-10-24 07:39:06 (GMT)
committerMatthew Weigel <Matthew.Weigel@freescale.com>2014-12-11 18:38:56 (GMT)
commitd686c7b10a2ff6a389c62db631c9a2efe6d205a9 (patch)
treededd74d7181cc4f420ebb491cf41c8644200b38c /drivers/spi
parentd54b013df4292fe2d3528e0cd9df4feac49ef896 (diff)
downloadlinux-fsl-qoriq-d686c7b10a2ff6a389c62db631c9a2efe6d205a9.tar.xz
spi:dspi:revert devm_kzalloc for calltrace issue
ac279ed96fd1262aa99c57246174(spi: fsl-dspi: Fix memory leak) converted the SPI device controller state to use devm_kzalloc(). Unfortunately, this is used against an unbound struct device, which results in the following when the device is eventually bound to its driver: ------------[ cut here ]------------ WARNING: CPU: 1 PID: 1 at drivers/base/dd.c:272 driver_probe_device+0x58/0x1d8() Modules linked in: CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.12.19-rt30+ #358 Backtrace: [<80010a08>] (dump_backtrace+0x0/0x100) from [<80010cb8>] (show_stack+0x18/0x1c) r6:804cef6e r5:00000009 r4:00000000 r3:00200140 [<80010ca0>] (show_stack+0x0/0x1c) from [<803e5c24>] (dump_stack+0x78/0x94) [<803e5bac>] (dump_stack+0x0/0x94) from [<8001c554>] (warn_slowpath_common+0x6c/0x90) r4:00000000 r3:60000113 [<8001c4e8>] (warn_slowpath_common+0x0/0x90) from [<8001c61c>] (warn_slowpath_null+0x24/0x2c) r8:e6ffc314 r7:805652e4 r6:8059498c r5:e6ffc200 r4:e6ffc200 [<8001c5f8>] (warn_slowpath_null+0x0/0x2c) from [<80231590>] (driver_probe_device+0x58/0x1d8) [<80231538>] (driver_probe_device+0x0/0x1d8) from [<80231740>] (__device_attach+0x30/0x4c) r7:00000000 r6:80231710 r5:e6ffc200 r4:805652e4 [<80231710>] (__device_attach+0x0/0x4c) from [<8022fc18>] (bus_for_each_drv+0x80/0x94) r5:e6ffc200 r4:00000000 [<8022fb98>] (bus_for_each_drv+0x0/0x94) from [<802314f8>] (device_attach+0x70/0x88) r6:e6ffc200 r5:e6ffc234 r4:e6ffc200 [<80231488>] (device_attach+0x0/0x88) from [<80230aa4>] (bus_probe_device+0x30/0xa0) r6:e6ffc200 r5:80565e3c r4:e6ffc200 r3:00000001 [<80230a74>] (bus_probe_device+0x0/0xa0) from [<8022ef0c>] (device_add+0x4f0/0x5c8) r6:e6ffc208 r5:00000000 r4:e6ffc200 r3:00000001 [<8022ea1c>] (device_add+0x0/0x5c8) from [<8026fb20>] (spi_add_device+0xe8/0x138) [<8026fa38>] (spi_add_device+0x0/0x138) from [<80270a78>] (spi_register_master+0x5e4/0x6c8) r7:00000000 r6:815b9ec8 r5:e6ffc200 r4:e6ff8000 [<80270494>] (spi_register_master+0x0/0x6c8) from [<8027196c>] (dspi_probe+0x268/0x314) [<80271704>] (dspi_probe+0x0/0x314) from [<80232668>] (platform_drv_probe+0x1c/0x20) [<8023264c>] (platform_drv_probe+0x0/0x20) from [<802315dc>] (driver_probe_device+0xa4/0x1d8) [<80231538>] (driver_probe_device+0x0/0x1d8) from [<802317cc>] (__driver_attach+0x70/0x94) r7:00000000 r6:80565f88 r5:e6d07e44 r4:e6d07e10 [<8023175c>] (__driver_attach+0x0/0x94) from [<8022fb60>] (bus_for_each_dev+0x7c/0x90) r6:8023175c r5:80565f88 r4:00000000 r3:8023175c [<8022fae4>] (bus_for_each_dev+0x0/0x90) from [<80231148>] (driver_attach+0x20/0x28) r6:e6fd6e00 r5:80563ab8 r4:80565f88 [<80231128>] (driver_attach+0x0/0x28) from [<80230cec>] (bus_add_driver+0xe4/0x248) [<80230c08>] (bus_add_driver+0x0/0x248) from [<80231c1c>] (driver_register+0xa4/0xe8) r7:80572440 r6:8052d464 r5:8053a1cc r4:80565f88 [<80231b78>] (driver_register+0x0/0xe8) from [<80232b80>] (__platform_driver_register+0x50/0x64) r5:8053a1cc r4:00000006 [<80232b30>] (__platform_driver_register+0x0/0x64) from [<8052d47c>] (fsl_dspi_driver_init+0x18/0x20) [<8052d464>] (fsl_dspi_driver_init+0x0/0x20) from [<800087fc>] (do_one_initcall+0x98/0x134) [<80008764>] (do_one_initcall+0x0/0x134) from [<80515c68>] (kernel_init_freeable+0x110/0x1d8) r9:0000009f r8:80572440 r7:80572440 r6:80541324 r5:8053a1cc r4:00000006 [<80515b58>] (kernel_init_freeable+0x0/0x1d8) from [<803e0838>] (kernel_init+0x14/0xec) r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:803e0824 r4:80572440 [<803e0824>] (kernel_init+0x0/0xec) from [<8000dd58>] (ret_from_fork+0x14/0x3c) r4:00000000 r3:00000000 ---[ end trace ef66b8df97ff1e33 ]--- Fix this by partially reverting the original commit. Signed-off-by: Chao Fu <B44548@freescale.com> Change-Id: I234e49f6cda0f5125d1b6d6990112b4ff3fe33a4 Reviewed-on: http://git.am.freescale.net:8181/21975 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Zhengxiong Jin <Jason.Jin@freescale.com>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-fsl-dspi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index ec0ad01..a6df59e 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -399,8 +399,7 @@ static int dspi_setup(struct spi_device *spi)
/* Only alloc on first setup */
chip = spi_get_ctldata(spi);
if (chip == NULL) {
- chip = devm_kzalloc(&spi->dev, sizeof(struct chip_data),
- GFP_KERNEL);
+ chip = kcalloc(1, sizeof(struct chip_data), GFP_KERNEL);
if (!chip)
return -ENOMEM;
}
@@ -411,6 +410,7 @@ static int dspi_setup(struct spi_device *spi)
fmsz = spi->bits_per_word - 1;
} else {
pr_err("Invalid wordsize\n");
+ kfree(chip);
return -ENODEV;
}