Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751619AbcDRWe2 (ORCPT ); Mon, 18 Apr 2016 18:34:28 -0400 Received: from down.free-electrons.com ([37.187.137.238]:35205 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751126AbcDRWe1 (ORCPT ); Mon, 18 Apr 2016 18:34:27 -0400 Date: Tue, 19 Apr 2016 00:34:14 +0200 From: Alexandre Belloni To: Steve Twiss Cc: LINUXKERNEL , RTC-LINUX , Support Opensource Subject: Re: [PATCH V1] rtc: da9053: fix access ordering error during RTC interrupt at system power on Message-ID: <20160418223414.GB25196@piout.net> References: <20160414111014.BB8B73FB1D@swsrvapps-01.diasemi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160414111014.BB8B73FB1D@swsrvapps-01.diasemi.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1486 Lines: 41 On 14/04/2016 at 12:04:54 +0100, Steve Twiss wrote : > From: Steve Twiss > > This fix alters the ordering of the IRQ and device registrations in the RTC > driver probe function. This change will apply to the RTC driver that supports > both DA9052 and DA9053 PMICs. > > A problem could occur with the existing RTC driver if: > > A system is started from a cold boot using the PMIC RTC IRQ to initiate a > power on operation. For instance, if an RTC alarm is used to start a > platform from power off. > The existing driver IRQ is requested before the device has been properly > registered. > > i.e. > ret = da9052_request_irq() > comes before > rtc->rtc = devm_rtc_device_register(); > > In this case, an interrupt exists before the device has been registered and > the IRQ handler can be called immediately: this can happen be before the > memory for rtc->rtc has been allocated. The IRQ handler da9052_rtc_irq() > contains the function call: > > rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF); > > which in turn tries to access the unavailable rtc->rtc. > > The fix is to reorder the functions inside the RTC probe. The IRQ is > requested after the RTC device resource has been registered so that > da9052_request_irq() is the last thing to happen. > > Signed-off-by: Steve Twiss > Applied, thanks. -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com