mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Kshitiz Varshney <kshitiz.varshney@nxp.com>,
	Horia Geanta <horia.geanta@nxp.com>,
	Pankaj Gupta <pankaj.gupta@nxp.com>,
	Varun Sethi <V.Sethi@nxp.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S . Miller" <davem@davemloft.net>,
	Iuliana Prodan <iuliana.prodan@nxp.com>,
	Gaurav Jain <gaurav.jain@nxp.com>,
	Rahul Kumar Yadav <rahulkumar.yadav@nxp.com>,
	Vabhav Sharma <vabhav.sharma@nxp.com>,
	Sahil Malhotra <sahil.malhotra@nxp.com>,
	Matt Mackall <mpm@selenic.com>, Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Steffen Trumtrar <s.trumtrar@pengutronix.de>,
	PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>,
	Martin Kaiser <martin@kaiser.cx>
Cc: linux-imx@nxp.com, linux-crypto@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] Moving init_completion before request_irq
Date: Fri, 29 Jul 2022 12:21:31 +0200	[thread overview]
Message-ID: <e78ff391-3141-bf0b-6fe1-4ff7204414fb@pengutronix.de> (raw)
In-Reply-To: <20220729100211.2204126-1-kshitiz.varshney@nxp.com>

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 <kshitiz.varshney@nxp.com>

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 |

  reply	other threads:[~2022-07-29 10:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29 10:02 Kshitiz Varshney
2022-07-29 10:21 ` Ahmad Fatoum [this message]
2022-07-30 15:00   ` Martin Kaiser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e78ff391-3141-bf0b-6fe1-4ff7204414fb@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=V.Sethi@nxp.com \
    --cc=davem@davemloft.net \
    --cc=festevam@gmail.com \
    --cc=gaurav.jain@nxp.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=horia.geanta@nxp.com \
    --cc=iuliana.prodan@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=kshitiz.varshney@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin@kaiser.cx \
    --cc=mpm@selenic.com \
    --cc=pankaj.gupta@nxp.com \
    --cc=prasannatsmkumar@gmail.com \
    --cc=rahulkumar.yadav@nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=s.trumtrar@pengutronix.de \
    --cc=sahil.malhotra@nxp.com \
    --cc=shawnguo@kernel.org \
    --cc=vabhav.sharma@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®