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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 267D2C00144 for ; Fri, 29 Jul 2022 10:22:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235894AbiG2KWC (ORCPT ); Fri, 29 Jul 2022 06:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235375AbiG2KV6 (ORCPT ); Fri, 29 Jul 2022 06:21:58 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A08C677579 for ; Fri, 29 Jul 2022 03:21:57 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1oHN7j-0002Ai-P4; Fri, 29 Jul 2022 12:21:39 +0200 Message-ID: Date: Fri, 29 Jul 2022 12:21:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v1] Moving init_completion before request_irq Content-Language: en-US To: Kshitiz Varshney , Horia Geanta , Pankaj Gupta , Varun Sethi , Herbert Xu , "David S . Miller" , Iuliana Prodan , Gaurav Jain , Rahul Kumar Yadav , Vabhav Sharma , Sahil Malhotra , Matt Mackall , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Steffen Trumtrar , PrasannaKumar Muralidharan , Martin Kaiser Cc: linux-imx@nxp.com, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220729100211.2204126-1-kshitiz.varshney@nxp.com> From: Ahmad Fatoum In-Reply-To: <20220729100211.2204126-1-kshitiz.varshney@nxp.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Kshitiz, On 29.07.22 12:02, Kshitiz Varshney wrote: > Issue: > While servicing interrupt, trying to access variable rng_op_done, > which is not yet initalized hence causing kernel to crash > while booting. > > Fix: > Moving initialization of rng_op_done before request_irq. > > Fixes: 1d5449445bd0 (hwrng: mx-rngc - add a driver for Freescale RNGC) > Signed-off-by: Kshitiz Varshney Thanks for your patch. > + init_completion(&rngc->rng_op_done); > + > ret = devm_request_irq(&pdev->dev, > irq, imx_rngc_irq, 0, pdev->name, (void *)rngc); This should probably be moved below imx_rngc_irq_mask_clear(rngc). init_completion can stay where it is. That way: - You initialize rngc fully before registering the IRQ handler - You don't handle pending IRQs that you want to dismiss anyway - If the IRQ happens to be because of a SEED_DONE due to a previous boot stage, you don't end up completing the completion prematurely. Cheers, Ahmad > if (ret) { > @@ -277,7 +279,6 @@ static int imx_rngc_probe(struct platform_device *pdev) > goto err; > } > > - init_completion(&rngc->rng_op_done); > > rngc->rng.name = pdev->name; > rngc->rng.init = imx_rngc_init; -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |