lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201119153540.zehj2ppdt433xrsv@pengutronix.de>
Date:   Thu, 19 Nov 2020 16:35:40 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Mark Brown <broonie@...nel.org>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org, kernel@...gutronix.de,
        linux-spi@...r.kernel.org
Subject: Re: [PATCH 1/3] spi: fix resource leak for drivers without .remove
 callback

On Thu, Nov 19, 2020 at 03:24:16PM +0000, Mark Brown wrote:
> On Thu, Nov 19, 2020 at 04:20:57PM +0100, Uwe Kleine-König wrote:
> > Consider an spi driver with a .probe but without a .remove callback (e.g.
> > rtc-ds1347). The function spi_drv_probe() is called to bind a device and
> > so some init routines like dev_pm_domain_attach() are used. As there is
> > no remove callback spi_drv_remove() isn't called at unbind time however
> > and so calling dev_pm_domain_detach() is missed and the pm domain keeps
> > active.
> 
> > To fix this always use either both or none of the functions and make
> > them handle the callback not being set.
> 
> Why would we want to tie configuring PM domains to either of these
> functions?  We certainly don't want to force drivers to have empty
> remove functions to trigger cleanup of domains, this would be
> counterintuitive and this stuff should be transparent to the driver.

Yes, I thought that this is not the final fix. I just sent the minimal
change to prevent the imbalance. So if I understand correctly, I will
have to respin with the following squashed into patch 1:

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5bdc66f08ee1..5becf6c2c409 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -445,10 +445,8 @@ int __spi_register_driver(struct module *owner, struct spi_driver *sdrv)
 {
 	sdrv->driver.owner = owner;
 	sdrv->driver.bus = &spi_bus_type;
-	if (sdrv->probe || sdrv->remove) {
-		sdrv->driver.probe = spi_drv_probe;
-		sdrv->driver.remove = spi_drv_remove;
-	}
+	sdrv->driver.probe = spi_drv_probe;
+	sdrv->driver.remove = spi_drv_remove;
 	if (sdrv->shutdown)
 		sdrv->driver.shutdown = spi_drv_shutdown;
 	return driver_register(&sdrv->driver);

(Not sure this makes a difference in real life, are there drivers
without a .probe callback?)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ