Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3285003ybi; Fri, 19 Jul 2019 00:35:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHZUqscY9Fzs71aDjq4JApt9rwO8R3jYVSecRfTwXejqpOpLEnpbAr3aG0XX78VzOtntul X-Received: by 2002:a63:b20f:: with SMTP id x15mr54145964pge.453.1563521725809; Fri, 19 Jul 2019 00:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563521725; cv=none; d=google.com; s=arc-20160816; b=FZq8A+zVfI8BDBgcMaDcLF7CxzpNwbOK5rkFKAlonxgq9oqQhtfHs1GkNyS/damTHf bhsCau/E+P+SAAOiwr6lBox5gSxrMe6/DJY1PqnekM7oVcipE4CXOlhXRvAKSNCXNle9 NeP6vYYLDmDfCD0tqDinBknse70hK3zENAwj6Jmi4RbrIkdZd7a26SH1s9QmwebeqqmG 2AO1lQZrtWBOMYRSWkRP+TPqv+78TM0nOhI0nb2I7I9mtS57hpeyQH/9UJQVkiR1o+nY B5+ZxEpU7Exw/fu/8MHB8rWOIOvYgeHVTxEtKZ5q8/fe/xagYoKmE0nKWMnQVrEbd/jW TN9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=uUx/7pHCX261pC/IjQKjyxZ2S9rFz00S8Dtu+ogcDfg=; b=MUUda2kLr57dJho7HKfvbHy0VLhSHho0nJdm+aMxAsKdL1p/nrw/cfpCKcnFOJCDKN wTt+LxD6895zFdg+zlnyq8wCueD4S1HjN0saETv6JJfpLAXtRK11cAbAYvEVbp53/9bN 1jG8LnRygqORRy37E0k55/Ws+NB3QpR1GO9dAhn0iHdMquQXG0wA0Bj500OFRTvvyuqA kpj7aVgz95QhTjB/vOYQuvkUBV7wJl7xb1IcfbSPGm9BUe3grbw52IpNr5mKQJBrE8ae bfpNi/nMqIdc3aFharbt1DbPqdOpCCeB3OuZqVf1JoTQiQuaQy5azp59io7w9mczxymq Jksw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s66si772554pgs.592.2019.07.19.00.35.10; Fri, 19 Jul 2019 00:35:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727376AbfGSHdV (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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