From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752072AbcGRXAA (ORCPT ); Mon, 18 Jul 2016 19:00:00 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:59270 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751767AbcGRW77 (ORCPT ); Mon, 18 Jul 2016 18:59:59 -0400 Date: Mon, 18 Jul 2016 23:59:52 +0100 From: Mark Brown To: Michal Suchanek Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <20160718225952.GW30372@sirena.org.uk> References: <5bfcceff7b6132cf3447f97c24d1646043224164.1468880530.git.hramrach@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rUGnr7B6Y4qPBmNO" Content-Disposition: inline In-Reply-To: <5bfcceff7b6132cf3447f97c24d1646043224164.1468880530.git.hramrach@gmail.com> X-Cookie: It's later than you think. User-Agent: Mutt/1.6.0 (2016-04-01) X-SA-Exim-Connect-IP: 2a01:348:6:8808:fab::3 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Re: [PATCH v3 1/3] spi: spidev: create spidev device for all spi slaves. X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --rUGnr7B6Y4qPBmNO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jul 19, 2016 at 12:35:40AM +0200, Michal Suchanek wrote: > config SPI_SPIDEV > - tristate "User mode SPI device driver support" > + bool "User mode SPI device driver support" This is a step back, it would require spidev to be built in. > - spin_lock_irq(&spidev->spi_lock); > - spi = spi_dev_get(spidev->spi); > - spin_unlock_irq(&spidev->spi_lock); > + spi = filp->private_data; > + spi = spi_dev_get(spi); All this refactoring to move spidev about should've been a separate patch, it's hard to find the actual content in here. > - mutex_lock(&device_list_lock); > + dev = bus_find_device(&spi_bus_type, NULL, (void *) inode->i_rdev, > + spidev_devt_match); ... > - dev_dbg(&spidev->spi->dev, "open/ENOMEM\n"); > + spi = to_spi_device(dev); > + > + mutex_lock(&spi->buf_lock); > + spin_lock_irq(&spi->spidev_lock); > + spi->spidev_users++; > + spin_unlock_irq(&spi->spidev_lock); This is broken, it will unconditionally create a spidev for any chip select regardless of if there's any actual hardware there and (even more importantly) regardless if that hardware is actually a SPI device. This is not safe, especially given some of the ideas people seem to have for userspaces. I am getting completely fed up of saying this, it's not OK to just expose pins to userspace when we have no idea what they are connected to. --rUGnr7B6Y4qPBmNO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXjV9mAAoJECTWi3JdVIfQ2t8H/i2kXUfb6Gx/DK445oaNOSAk qpbYGPhZyLmK3phAfLbMlxvFy9m5bOy/HuouuyTkZEGmkZc2KTj0dK8lyQdWAtQk IvpZu1XmEK2QfhyLhdlCsv6nqmOIqG+NR2sUIsJxS9XRgqs5x7q/R2fifrjBxZqZ rQpgxBrUFeTr53Dlu7G+AUreQX4gfCB7fQQk01jLetwPLknumidjoSe15Yqidtik YTeFS/JZDJmohtbe3/VPKFbk6H3mMgI/2VTXFj7FJ0qfpbhX+KAfo5VIUFleJyNj lAEeY78pa7Oe9rJqtrHYfCtc+CUZx7SasB4wOWni8BicL2HV6PC4ASstjinWdac= =ARz4 -----END PGP SIGNATURE----- --rUGnr7B6Y4qPBmNO--