linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vegard Nossum <vegard.nossum-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] spi: spidev: Hold spi_lock over all defererences of spi in release()
Date: Tue, 17 Nov 2015 09:11:58 +0100	[thread overview]
Message-ID: <564AE14E.1030008@oracle.com> (raw)
In-Reply-To: <1447689999-20632-1-git-send-email-broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

On 11/16/2015 05:06 PM, Mark Brown wrote:
> We use the spi_lock spinlock to protect against races between the device
> being removed and file operations on the spidev.  This means that in the
> removal path all references to the device need to be done under lock as
> in removal we dropping references to the device.
>
> Reported-by: Vegard Nossum <vegard.nossum-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> ---
>   drivers/spi/spidev.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
> index 91a0fcd72423..d0e7dfc647cf 100644
> --- a/drivers/spi/spidev.c
> +++ b/drivers/spi/spidev.c
> @@ -651,11 +651,11 @@ static int spidev_release(struct inode *inode, struct file *filp)
>   		kfree(spidev->rx_buffer);
>   		spidev->rx_buffer = NULL;
>
> +		spin_lock_irq(&spidev->spi_lock);
>   		if (spidev->spi)
>   			spidev->speed_hz = spidev->spi->max_speed_hz;
>
>   		/* ... after we unbound from the underlying device? */
> -		spin_lock_irq(&spidev->spi_lock);
>   		dofree = (spidev->spi == NULL);
>   		spin_unlock_irq(&spidev->spi_lock);
>
>

Thanks for the patch! We should probably add a stable CC too (since it
fixes "spi: spidev: fix possible NULL dereference" which went into stable):

Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>


Vegard
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-11-17  8:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-16 16:06 [PATCH] spi: spidev: Hold spi_lock over all defererences of spi in release() Mark Brown
     [not found] ` <1447689999-20632-1-git-send-email-broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-11-17  8:11   ` Vegard Nossum [this message]
2015-12-16 13:27   ` Applied "spi: spidev: Hold spi_lock over all defererences of spi in release()" to the spi tree Mark Brown

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=564AE14E.1030008@oracle.com \
    --to=vegard.nossum-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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).