Re: [PATCH] spi: s3c64xx: Don't free controller_data on non-dt platforms

2012-09-22 Thread Mark Brown
On Thu, Sep 13, 2012 at 04:31:30PM +0200, Sylwester Nawrocki wrote:
> When s3c64xx-spi is instantiated from device tree an instance of
> struct s3c64xx_spi_csinfo is dynamically allocated in the driver.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] spi: s3c64xx: Don't free controller_data on non-dt platforms

2012-09-13 Thread Kukjin Kim
Sylwester Nawrocki wrote:
> 
> When s3c64xx-spi is instantiated from device tree an instance of
> struct s3c64xx_spi_csinfo is dynamically allocated in the driver.
> For non-dt platform it is passed from board code through
> spi_register_board_info(). On error path in s3c64xx_spi_setup()
> function there is an attempt to free this data struct
> s3c64xx_spi_csinfo object as it would have been allocated in the
> driver for both, dt and non-dt based platforms. This leads to
> following bug when gpio request fails:
> 
> spi spi1.0: Failed to get /CS gpio [21]: -16
> kernel BUG at mm/slub.c:3478!
> Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
> Modules linked in:
> CPU: 0Not tainted  (3.6.0-rc5-00092-g9b0b493-dirty #6111)
> PC is at kfree+0x148/0x158
> LR is at s3c64xx_spi_setup+0xac/0x290
> pc : []lr : []psr: 4013
> sp : ee043e10  ip : c032883c  fp : c0481f7c
> r10: ee0abd80  r9 : 0063  r8 : 
> r7 : ee129e78  r6 : ee104a00  r5 : fff0  r4 : c047bc64
> r3 : 4400  r2 : c047bc64  r1 : c04def60  r0 : 0004047b
> Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
> Control: 10c5387d  Table: 4000404a  DAC: 0015
> Process swapper/0 (pid: 1, stack limit = 0xee0422f0)
> Stack: (0xee043e10 to 0xee044000)
> ...
> [] (kfree+0x148/0x158) from []
> (s3c64xx_spi_setup+0xac/0x290)
> [] (s3c64xx_spi_setup+0xac/0x290) from []
> (spi_setup+0x34/0x4c)
> [] (spi_setup+0x34/0x4c) from []
> (spi_add_device+0x98/0x128)
> [] (spi_add_device+0x98/0x128) from []
> (spi_new_device+0x74/0xa8)
> [] (spi_new_device+0x74/0xa8) from []
> (spi_match_master_to_boardinfo+0x24/0x44)
> [] (spi_match_master_to_boardinfo+0x24/0x44) from []
> (spi_register_master+0xf4/0x2a8)
> [] (spi_register_master+0xf4/0x2a8) from []
> (s3c64xx_spi_probe+0x34c/0x42c)
> [] (s3c64xx_spi_probe+0x34c/0x42c) from []
> (platform_drv_probe+0x18/0x1c)
> 
> There should be no attempt to kfree controller_data when it was
> externally provided through the board code. Fix this by freeing
> controller_data only when dev->of_node is not null.
> 
> Signed-off-by: Sylwester Nawrocki 
> Signed-off-by: Kyungmin Park 

Yes, correct. Need to check it.

Acked-by: Kukjin Kim 

Thanks.

Best regards,
Kgene.
--
Kukjin Kim , Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] spi: s3c64xx: Don't free controller_data on non-dt platforms

2012-09-13 Thread Sylwester Nawrocki
When s3c64xx-spi is instantiated from device tree an instance of
struct s3c64xx_spi_csinfo is dynamically allocated in the driver.
For non-dt platform it is passed from board code through
spi_register_board_info(). On error path in s3c64xx_spi_setup()
function there is an attempt to free this data struct
s3c64xx_spi_csinfo object as it would have been allocated in the
driver for both, dt and non-dt based platforms. This leads to
following bug when gpio request fails:

spi spi1.0: Failed to get /CS gpio [21]: -16
kernel BUG at mm/slub.c:3478!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 0Not tainted  (3.6.0-rc5-00092-g9b0b493-dirty #6111)
PC is at kfree+0x148/0x158
LR is at s3c64xx_spi_setup+0xac/0x290
pc : []lr : []psr: 4013
sp : ee043e10  ip : c032883c  fp : c0481f7c
r10: ee0abd80  r9 : 0063  r8 : 
r7 : ee129e78  r6 : ee104a00  r5 : fff0  r4 : c047bc64
r3 : 4400  r2 : c047bc64  r1 : c04def60  r0 : 0004047b
Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 10c5387d  Table: 4000404a  DAC: 0015
Process swapper/0 (pid: 1, stack limit = 0xee0422f0)
Stack: (0xee043e10 to 0xee044000)
...
[] (kfree+0x148/0x158) from [] 
(s3c64xx_spi_setup+0xac/0x290)
[] (s3c64xx_spi_setup+0xac/0x290) from [] 
(spi_setup+0x34/0x4c)
[] (spi_setup+0x34/0x4c) from [] (spi_add_device+0x98/0x128)
[] (spi_add_device+0x98/0x128) from [] 
(spi_new_device+0x74/0xa8)
[] (spi_new_device+0x74/0xa8) from [] 
(spi_match_master_to_boardinfo+0x24/0x44)
[] (spi_match_master_to_boardinfo+0x24/0x44) from [] 
(spi_register_master+0xf4/0x2a8)
[] (spi_register_master+0xf4/0x2a8) from [] 
(s3c64xx_spi_probe+0x34c/0x42c)
[] (s3c64xx_spi_probe+0x34c/0x42c) from [] 
(platform_drv_probe+0x18/0x1c)

There should be no attempt to kfree controller_data when it was
externally provided through the board code. Fix this by freeing
controller_data only when dev->of_node is not null.

Signed-off-by: Sylwester Nawrocki 
Signed-off-by: Kyungmin Park 
---
 drivers/spi/spi-s3c64xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index d1c8441f..7f75d4e 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -976,7 +976,8 @@ err_msgq:
spi_set_ctldata(spi, NULL);

 err_gpio_req:
-   kfree(cs);
+   if (spi->dev.of_node)
+   kfree(cs);

return err;
 }
--
1.7.11.3

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html