From: Lukasz Majewski <lukma@denx.de>
To: Mark Brown <broonie@kernel.org>,
Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Colin Ian King <colin.king@canonical.com>,
linux-spi@vger.kernel.org, krzk@kernel.org,
linux-kernel@vger.kernel.org, Lukasz Majewski <lukma@denx.de>,
kbuild test robot <lkp@intel.com>,
Julia Lawall <julia.lawall@lip6.fr>,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH] spi: Avoid calling spi_slave_abort() with kfreed spidev
Date: Tue, 1 Oct 2019 11:06:57 +0200 [thread overview]
Message-ID: <20191001090657.25721-1-lukma@denx.de> (raw)
Call spi_slave_abort() only when the spidev->spi is !NULL and the
structure hasn't already been kfreed.
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
This fix applies on:
repo: https://kernel.googlesource.com/pub/scm/linux/kernel/git/broonie/spi.git
branch: for-5.4
SHA1: 6b04e47b73f2a0d2c330cecca99f8e2cb8f85b34
---
drivers/spi/spidev.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 3ea9d8a3e6e8..2c6d4dbeebac 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -600,15 +600,16 @@ static int spidev_open(struct inode *inode, struct file *filp)
static int spidev_release(struct inode *inode, struct file *filp)
{
struct spidev_data *spidev;
+ int dofree;
mutex_lock(&device_list_lock);
spidev = filp->private_data;
filp->private_data = NULL;
+ dofree = 0;
/* last close? */
spidev->users--;
if (!spidev->users) {
- int dofree;
kfree(spidev->tx_buffer);
spidev->tx_buffer = NULL;
@@ -628,7 +629,8 @@ static int spidev_release(struct inode *inode, struct file *filp)
kfree(spidev);
}
#ifdef CONFIG_SPI_SLAVE
- spi_slave_abort(spidev->spi);
+ if (!dofree)
+ spi_slave_abort(spidev->spi);
#endif
mutex_unlock(&device_list_lock);
--
2.20.1
next reply other threads:[~2019-10-01 9:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 9:06 Lukasz Majewski [this message]
2019-10-01 9:15 ` [PATCH] spi: Avoid calling spi_slave_abort() with kfreed spidev Geert Uytterhoeven
2019-10-01 9:34 ` Lukasz Majewski
2019-10-01 10:00 ` Geert Uytterhoeven
2019-10-01 11:07 ` Lukasz Majewski
2019-10-01 11:41 ` 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=20191001090657.25721-1-lukma@denx.de \
--to=lukma@denx.de \
--cc=broonie@kernel.org \
--cc=colin.king@canonical.com \
--cc=dan.carpenter@oracle.com \
--cc=geert@linux-m68k.org \
--cc=julia.lawall@lip6.fr \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=lkp@intel.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).