From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4C3CC76195 for ; Fri, 19 Jul 2019 07:33:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9FE0B20659 for ; Fri, 19 Jul 2019 07:33:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727317AbfGSHdV (ORCPT ); Fri, 19 Jul 2019 03:33:21 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:55139 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbfGSHdU (ORCPT ); Fri, 19 Jul 2019 03:33:20 -0400 X-Originating-IP: 92.137.69.152 Received: from localhost (alyon-656-1-672-152.w92-137.abo.wanadoo.fr [92.137.69.152]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id E4CA8240008; Fri, 19 Jul 2019 07:33:17 +0000 (UTC) Date: Fri, 19 Jul 2019 09:33:16 +0200 From: Alexandre Belloni To: Anson.Huang@nxp.com Cc: a.zummo@towertech.it, linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Linux-imx@nxp.com Subject: Re: [PATCH V2] rtc: snvs: fix possible race condition Message-ID: <20190719073316.GA4012@piout.net> References: <20190719030102.6141-1-Anson.Huang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190719030102.6141-1-Anson.Huang@nxp.com> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org On 19/07/2019 11:01:02+0800, Anson.Huang@nxp.com wrote: > From: Anson Huang > > The RTC IRQ is requested before the struct rtc_device is allocated, > this may lead to a NULL pointer dereference in IRQ handler. > > To fix this issue, allocating the rtc_device struct and register rtc > device before requesting the RTC IRQ. > > Using devm_rtc_allocate_device/rtc_register_device instead of > devm_rtc_device_register. > > Signed-off-by: Anson Huang > --- > Changes since V1: > - move devm_request_irq() to after rtc device register done, make sure everything > is ready before enabling IRQ. This opens another race condition, the first version of the patch was correct. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com