From patchwork Wed Aug 29 10:11:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Wu X-Patchwork-Id: 1384451 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 5BEBEDF215 for ; Wed, 29 Aug 2012 10:20:26 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T6fKI-0008Q3-Qz; Wed, 29 Aug 2012 10:16:46 +0000 Received: from bombadil.infradead.org ([2001:4830:2446:ff00:4687:fcff:fea6:5117]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T6fKG-0008Py-HC for linux-arm-kernel@merlin.infradead.org; Wed, 29 Aug 2012 10:16:44 +0000 Received: from newsmtp5.atmel.com ([204.2.163.5] helo=sjogate2.atmel.com) by bombadil.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T6fKE-0002QG-A2 for linux-arm-kernel@lists.infradead.org; Wed, 29 Aug 2012 10:16:43 +0000 Received: from penbh01.corp.atmel.com ([10.168.5.31]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id q7TABbuN014257; Wed, 29 Aug 2012 03:11:38 -0700 (PDT) Received: from penmb01.corp.atmel.com ([10.168.5.33]) by penbh01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 29 Aug 2012 18:16:26 +0800 Received: from shaarm01.corp.atmel.com ([10.217.6.34]) by penmb01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 29 Aug 2012 18:16:25 +0800 From: Josh Wu To: g.liakhovetski@gmx.de, linux-media@vger.kernel.org Subject: [PATCH] [media] atmel_isi: allocate memory to store the isi platform data. Date: Wed, 29 Aug 2012 18:11:33 +0800 Message-Id: <1346235093-28613-1-git-send-email-josh.wu@atmel.com> X-Mailer: git-send-email 1.7.9.5 X-OriginalArrivalTime: 29 Aug 2012 10:16:26.0133 (UTC) FILETIME=[58FD4450:01CD85CF] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20120829_061642_692000_2AE1F222 X-CRM114-Status: GOOD ( 10.33 ) X-Spam-Score: -2.1 (--) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-2.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Josh Wu , nicolas.ferre@atmel.com, mchehab@redhat.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch fix the bug: ISI driver's platform data became invalid when isi platform data's attribution is __initdata. If the isi platform data is passed as __initdata. Then we need store it in driver allocated memory. otherwise when we use it out of the probe() function, then the isi platform data is invalid. Signed-off-by: Josh Wu --- drivers/media/platform/soc_camera/atmel-isi.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c index ec3f6a0..dc0fdec 100644 --- a/drivers/media/platform/soc_camera/atmel-isi.c +++ b/drivers/media/platform/soc_camera/atmel-isi.c @@ -926,6 +926,7 @@ static int __devexit atmel_isi_remove(struct platform_device *pdev) clk_put(isi->mck); clk_unprepare(isi->pclk); clk_put(isi->pclk); + kfree(isi->pdata); kfree(isi); return 0; @@ -968,8 +969,15 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev) goto err_alloc_isi; } + isi->pdata = kzalloc(sizeof(struct isi_platform_data), GFP_KERNEL); + if (!isi->pdata) { + ret = -ENOMEM; + dev_err(&pdev->dev, "Can't allocate isi platform data!\n"); + goto err_alloc_isi_pdata; + } + memcpy(isi->pdata, pdata, sizeof(struct isi_platform_data)); + isi->pclk = pclk; - isi->pdata = pdata; isi->active = NULL; spin_lock_init(&isi->lock); init_waitqueue_head(&isi->vsync_wq); @@ -1073,6 +1081,8 @@ err_set_mck_rate: err_clk_prepare_mck: clk_put(isi->mck); err_clk_get: + kfree(isi->pdata); +err_alloc_isi_pdata: kfree(isi); err_alloc_isi: clk_unprepare(pclk);