ARM fixes for 6.0

Just one fix for now for the AMBA bus code from Isaac Manjarres.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEuNNh8scc2k/wOAE+9OeQG+StrGQFAmMXuFIACgkQ9OeQG+St
 rGRCSRAAmKNCEAzciVrs8Zq7c1M+44ba5kbQxEFe4YkZyAVd/EEEhtQOFFxUA/BH
 drrUFLE6hBJH0sDMJ9o1c/AQe0GQ4L7tFwI5TqxIrThIy/9IwzBn6OTZpOTizlY9
 z84xymy33+4TsozmSNKbzEGRSCA/UYSjsIlCrEAtEzGqWmFtBaVEs6hGCdsPQp+J
 bnVHpnbDM5WgTnyOHKh9sQFWqA1bLiPQpNksdGcdIMtXdhfBrPySMubVZ6J2zhpo
 hxhsp5Zdp4j5odj5/0wpPWtDMMRDo7Duiir6ubz1nAdkF8JjjMW5bxaS9I90LuZg
 /73BS/8MZUkA0URI0uZoMl4qrqLytjBgCnLG3rYX6U1xo4A4dVkyx2uKuE/Q99YN
 WlC5sA941U+8xYdIhukd5yELQbCQiP0WOYJBEIEg69OsAIiDZboDydw46iq+K2eV
 f9pMxVa+evkZkfBmvfB3ow655CwybYhjTvAQqC2EyJnv8Fs/XCIA2jea5f/tlfCc
 e2nIkunPV7UlC/MAK87U0B4i8AjTWoTWspaAdjgdY6TfCL/VSNv5I6YBh/PWIvNp
 TnFYcw+Aq1V9CXW8G6J0/Nmjn8KmAFhhoC8zSqZNBbyFkfFuW0CyGCcXFEogOxaE
 uVk/n1geBeIHq5+u26A2c+IVmAjzpq853WsaCxWOmH9CdwN7l7E=
 =WHUk
 -----END PGP SIGNATURE-----

Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm

Pull ARM fix from Russell King:
 "Just one fix for now for the AMBA bus code from Isaac Manjarres"

* tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm:
  ARM: 9229/1: amba: Fix use-after-free in amba_read_periphid()
This commit is contained in:
Linus Torvalds 2022-09-06 21:27:05 -04:00
commit 19f516ea34
2 changed files with 8 additions and 1 deletions

View File

@ -209,6 +209,7 @@ static int amba_match(struct device *dev, struct device_driver *drv)
struct amba_device *pcdev = to_amba_device(dev); struct amba_device *pcdev = to_amba_device(dev);
struct amba_driver *pcdrv = to_amba_driver(drv); struct amba_driver *pcdrv = to_amba_driver(drv);
mutex_lock(&pcdev->periphid_lock);
if (!pcdev->periphid) { if (!pcdev->periphid) {
int ret = amba_read_periphid(pcdev); int ret = amba_read_periphid(pcdev);
@ -218,11 +219,14 @@ static int amba_match(struct device *dev, struct device_driver *drv)
* permanent failure in reading pid and cid, simply map it to * permanent failure in reading pid and cid, simply map it to
* -EPROBE_DEFER. * -EPROBE_DEFER.
*/ */
if (ret) if (ret) {
mutex_unlock(&pcdev->periphid_lock);
return -EPROBE_DEFER; return -EPROBE_DEFER;
}
dev_set_uevent_suppress(dev, false); dev_set_uevent_suppress(dev, false);
kobject_uevent(&dev->kobj, KOBJ_ADD); kobject_uevent(&dev->kobj, KOBJ_ADD);
} }
mutex_unlock(&pcdev->periphid_lock);
/* When driver_override is set, only bind to the matching driver */ /* When driver_override is set, only bind to the matching driver */
if (pcdev->driver_override) if (pcdev->driver_override)
@ -532,6 +536,7 @@ static void amba_device_release(struct device *dev)
if (d->res.parent) if (d->res.parent)
release_resource(&d->res); release_resource(&d->res);
mutex_destroy(&d->periphid_lock);
kfree(d); kfree(d);
} }
@ -584,6 +589,7 @@ static void amba_device_initialize(struct amba_device *dev, const char *name)
dev->dev.dma_mask = &dev->dev.coherent_dma_mask; dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
dev->dev.dma_parms = &dev->dma_parms; dev->dev.dma_parms = &dev->dma_parms;
dev->res.name = dev_name(&dev->dev); dev->res.name = dev_name(&dev->dev);
mutex_init(&dev->periphid_lock);
} }
/** /**

View File

@ -67,6 +67,7 @@ struct amba_device {
struct clk *pclk; struct clk *pclk;
struct device_dma_parameters dma_parms; struct device_dma_parameters dma_parms;
unsigned int periphid; unsigned int periphid;
struct mutex periphid_lock;
unsigned int cid; unsigned int cid;
struct amba_cs_uci_id uci; struct amba_cs_uci_id uci;
unsigned int irq[AMBA_NR_IRQS]; unsigned int irq[AMBA_NR_IRQS];