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: 1384591 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 36AD53FC71 for ; Wed, 29 Aug 2012 10:46:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752766Ab2H2KqX (ORCPT ); Wed, 29 Aug 2012 06:46:23 -0400 Received: from newsmtp5.atmel.com ([204.2.163.5]:51348 "EHLO sjogate2.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107Ab2H2KqW (ORCPT ); Wed, 29 Aug 2012 06:46:22 -0400 X-Greylist: delayed 1777 seconds by postgrey-1.27 at vger.kernel.org; Wed, 29 Aug 2012 06:46:22 EDT 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 Cc: linux-arm-kernel@lists.infradead.org, nicolas.ferre@atmel.com, mchehab@redhat.com, Josh Wu 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] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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);