From patchwork Thu Sep 13 14:31:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 1452811 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork2.kernel.org (Postfix) with ESMTP id 74540DF24C for ; Thu, 13 Sep 2012 14:32:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.b.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1TCASm-0007jK-8K; Thu, 13 Sep 2012 14:32:16 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1TCASl-0007j9-6U for spi-devel-general@lists.sourceforge.net; Thu, 13 Sep 2012 14:32:15 +0000 X-ACL-Warn: Received: from mailout1.samsung.com ([203.254.224.24]) by sog-mx-3.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1TCASe-00040p-1Y for spi-devel-general@lists.sourceforge.net; Thu, 13 Sep 2012 14:32:15 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MAA00JZ4LPD2RM0@mailout1.samsung.com> for spi-devel-general@lists.sourceforge.net; Thu, 13 Sep 2012 23:32:01 +0900 (KST) X-AuditID: cbfee61b-b7f826d000005fb5-68-5051ee612090 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B4.22.24501.16EE1505; Thu, 13 Sep 2012 23:32:01 +0900 (KST) Received: from amdc248.digital.local ([106.116.147.32]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MAA00108LP1LAC0@mmp2.samsung.com> for spi-devel-general@lists.sourceforge.net; Thu, 13 Sep 2012 23:32:01 +0900 (KST) From: Sylwester Nawrocki To: broonie@opensource.wolfsonmicro.com Subject: [PATCH] spi: s3c64xx: Don't free controller_data on non-dt platforms Date: Thu, 13 Sep 2012 16:31:30 +0200 Message-id: <1347546690-21848-1-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.11.3 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJJMWRmVeSWpSXmKPExsVy+t9jQd3Ed4EBBgc+SlkcmdLI7sDosXvB Z6YAxigum5TUnMyy1CJ9uwSujEvn1jMVzBStaDo7h7mB8ZdgFyMnh4SAiUTrurUsELaYxIV7 69lAbCGB6YwSx+eKdDFyAdmbmSS27VvKBJJgEzCU6D3ax9jFyMEhIqAusfW4DkiYWeAbo8S7 yVkgtrCAr8TRG81gM1kEVCX+/tzDDGLzCrhJbDqwmBVil6LEj+9rmCcwci9gZFjFKJpakFxQ nJSea6RXnJhbXJqXrpecn7uJEezBZ9I7GFc1WBxiFOBgVOLhzXweECDEmlhWXJl7iFGCg1lJ hFe9OzBAiDclsbIqtSg/vqg0J7X4EKM0B4uSOK/3eaCUQHpiSWp2ampBahFMlomDU6qB0cHw 0vqIv4XXbS9F7mJ5GnNMNG/r+cfmK/ik2Lqmb/4+QUw/fssvttlONt6ukv0Rsset5ERZMw5k lk9W9849tbZPbeaBVQl/Ct6Kfrygcf1KyYl0mwTxL79LE8I8njuxZk86dq6W90xeVXN8RmjW G7HDW/ij58lcW3n7WPz33Wc+XMvTeKf0U4mlOCPRUIu5qDgRANlSgrPcAQAA X-Spam-Score: -0.3 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 0.2 AWL AWL: From: address is in the auto white-list X-Headers-End: 1TCASe-00040p-1Y Cc: kgene.kim@samsung.com, sw0312.kim@samsung.com, Kyungmin Park , linux-samsung-soc@vger.kernel.org, thomas.abraham@linaro.org, Sylwester Nawrocki , spi-devel-general@lists.sourceforge.net X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net 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: 0 Not 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: 40000013 sp : ee043e10 ip : c032883c fp : c0481f7c r10: ee0abd80 r9 : 00000063 r8 : 00000000 r7 : ee129e78 r6 : ee104a00 r5 : fffffff0 r4 : c047bc64 r3 : 40000400 r2 : c047bc64 r1 : c04def60 r0 : 0004047b Flags: nZcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 10c5387d Table: 4000404a DAC: 00000015 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 Acked-by: Kukjin Kim --- drivers/spi/spi-s3c64xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.7.11.3 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ 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; }