linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: madhuparnabhowmik10@gmail.com
Cc: jacmet@sunsite.dk, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org,
	andrianov@ispras.ru
Subject: Re: [PATCH] usb/c67x00/c67x00-drv: Fix Data Race bug
Date: Fri, 28 Aug 2020 09:40:35 +0200	[thread overview]
Message-ID: <20200828074035.GB942935@kroah.com> (raw)
In-Reply-To: <20200826144459.8245-1-madhuparnabhowmik10@gmail.com>

On Wed, Aug 26, 2020 at 08:14:59PM +0530, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> 
> Currently in c67x00_drv_probe() IRQ is requested before calling
> c67x00_probe_sie() and hence if interrupt happens the reading of certain
> variables in the handler can race with initialization of the variables,
> for e.g. sie->sie_num is written in c67x00_probe_sie() and read in
>  c67x00_hcd_irq().
> Hence, this patch calls c67x00_probe_sie() before requesting IRQ in
> probe.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> ---
>  drivers/usb/c67x00/c67x00-drv.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/c67x00/c67x00-drv.c b/drivers/usb/c67x00/c67x00-drv.c
> index 53838e7d4eef..2e816d5ca0eb 100644
> --- a/drivers/usb/c67x00/c67x00-drv.c
> +++ b/drivers/usb/c67x00/c67x00-drv.c
> @@ -146,6 +146,9 @@ static int c67x00_drv_probe(struct platform_device *pdev)
>  	c67x00_ll_init(c67x00);
>  	c67x00_ll_hpi_reg_init(c67x00);
>  
> +	for (i = 0; i < C67X00_SIES; i++)
> +		c67x00_probe_sie(&c67x00->sie[i], c67x00, i);
> +
>  	ret = request_irq(res2->start, c67x00_irq, 0, pdev->name, c67x00);
>  	if (ret) {
>  		dev_err(&pdev->dev, "Cannot claim IRQ\n");
> @@ -158,9 +161,6 @@ static int c67x00_drv_probe(struct platform_device *pdev)
>  		goto reset_failed;
>  	}
>  
> -	for (i = 0; i < C67X00_SIES; i++)
> -		c67x00_probe_sie(&c67x00->sie[i], c67x00, i);
> -
>  	platform_set_drvdata(pdev, c67x00);
>  
>  	return 0;

Have you tested this on hardware to verify it works properly?

thanks,

greg k-h

  reply	other threads:[~2020-08-28  7:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26 14:44 [PATCH] usb/c67x00/c67x00-drv: Fix Data Race bug madhuparnabhowmik10
2020-08-28  7:40 ` Greg KH [this message]
2020-08-28 16:19   ` Madhuparna Bhowmik

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=20200828074035.GB942935@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andrianov@ispras.ru \
    --cc=jacmet@sunsite.dk \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=madhuparnabhowmik10@gmail.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;
as well as URLs for NNTP newsgroup(s).