From patchwork Sat May 7 01:20:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 1399 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:51:41 -0000 Delivered-To: patches@linaro.org Received: by 10.224.184.145 with SMTP id ck17cs162023qab; Fri, 6 May 2011 18:21:11 -0700 (PDT) Received: by 10.91.184.15 with SMTP id l15mr3958113agp.132.1304731271185; Fri, 06 May 2011 18:21:11 -0700 (PDT) Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx.google.com with ESMTPS id v12si10450111anq.180.2011.05.06.18.21.10 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 06 May 2011 18:21:10 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.153 as permitted sender) client-ip=32.97.110.153; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.153 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e35.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4714Kxn014884; Fri, 6 May 2011 19:04:20 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p471MCmF113786; Fri, 6 May 2011 19:22:12 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p471L2BH029625; Fri, 6 May 2011 19:21:02 -0600 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p471L20c029607; Fri, 6 May 2011 19:21:02 -0600 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 8EFBE1E7514; Fri, 6 May 2011 18:21:01 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Wolfram Sang , Alessandro Zummo , Thomas Gleixner , rtc-linux@googlegroups.com Subject: [PATCH 06/11] rtc: max8925: Initialize drvdata before registering device Date: Fri, 6 May 2011 18:20:49 -0700 Message-Id: <1304731254-3238-7-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1304731254-3238-1-git-send-email-john.stultz@linaro.org> References: <1304731254-3238-1-git-send-email-john.stultz@linaro.org> Commit f44f7f96a20 ("RTC: Initialize kernel state from RTC") uncovered an issue in a number of RTC drivers, where the drivers call rtc_device_register before initializing the device or platform drvdata. This frequently results in null pointer dereferences when the rtc_device_register immediately makes use of the rtc device, calling rtc_read_alarm. The solution is to ensure the drvdata is initialized prior to registering the rtc device. CC: Wolfram Sang CC: Alessandro Zummo CC: Thomas Gleixner CC: rtc-linux@googlegroups.com Signed-off-by: John Stultz --- drivers/rtc/rtc-max8925.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c index 20494b5..3bc046f 100644 --- a/drivers/rtc/rtc-max8925.c +++ b/drivers/rtc/rtc-max8925.c @@ -258,6 +258,8 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) } dev_set_drvdata(&pdev->dev, info); + /* XXX - isn't this redundant? */ + platform_set_drvdata(pdev, info); info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, &max8925_rtc_ops, THIS_MODULE); @@ -267,10 +269,9 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) goto out_rtc; } - platform_set_drvdata(pdev, info); - return 0; out_rtc: + platform_set_drvdata(pdev, NULL); free_irq(chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info); out_irq: kfree(info);