* [PATCH -next] vfio: platform: reset: add missing iounmap() on error in vfio_platform_amdxgbe_reset()
@ 2021-05-13 5:09 Yang Yingliang
2021-05-18 21:46 ` Alex Williamson
0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2021-05-13 5:09 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: eric.auger, alex.williamson
Add the missing iounmap() before return from vfio_platform_amdxgbe_reset()
in the error handling case.
Fixes: 0990822c9866 ("VFIO: platform: reset: AMD xgbe reset module")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c b/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c
index abdca900802d..c6d823a27bd6 100644
--- a/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c
+++ b/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c
@@ -61,8 +61,10 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
if (!xpcs_regs->ioaddr) {
xpcs_regs->ioaddr =
ioremap(xpcs_regs->addr, xpcs_regs->size);
- if (!xpcs_regs->ioaddr)
+ if (!xpcs_regs->ioaddr) {
+ iounmap(xgmac_regs->ioaddr);
return -ENOMEM;
+ }
}
/* reset the PHY through MDIO*/
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] vfio: platform: reset: add missing iounmap() on error in vfio_platform_amdxgbe_reset()
2021-05-13 5:09 [PATCH -next] vfio: platform: reset: add missing iounmap() on error in vfio_platform_amdxgbe_reset() Yang Yingliang
@ 2021-05-18 21:46 ` Alex Williamson
0 siblings, 0 replies; 2+ messages in thread
From: Alex Williamson @ 2021-05-18 21:46 UTC (permalink / raw)
To: Yang Yingliang; +Cc: linux-kernel, kvm, eric.auger
On Thu, 13 May 2021 13:09:24 +0800
Yang Yingliang <yangyingliang@huawei.com> wrote:
> Add the missing iounmap() before return from vfio_platform_amdxgbe_reset()
> in the error handling case.
>
> Fixes: 0990822c9866 ("VFIO: platform: reset: AMD xgbe reset module")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> drivers/vfio/platform/reset/vfio_platform_amdxgbe.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c b/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c
> index abdca900802d..c6d823a27bd6 100644
> --- a/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c
> +++ b/drivers/vfio/platform/reset/vfio_platform_amdxgbe.c
> @@ -61,8 +61,10 @@ static int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)
> if (!xpcs_regs->ioaddr) {
> xpcs_regs->ioaddr =
> ioremap(xpcs_regs->addr, xpcs_regs->size);
> - if (!xpcs_regs->ioaddr)
> + if (!xpcs_regs->ioaddr) {
> + iounmap(xgmac_regs->ioaddr);
> return -ENOMEM;
> + }
> }
>
> /* reset the PHY through MDIO*/
This actually introduces multiple bugs. vfio-platform has common code
for calling iounmap when the device is released and the struct
vfio_platform_region ioaddr member is re-used throughout the code.
Performing an iounmap() without setting the value to NULL essentially
introduces use-after-free and double free bugs. There's no bug in the
original afaict, the iounmap occurs lazily on release. Thanks,
Alex
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-18 21:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13 5:09 [PATCH -next] vfio: platform: reset: add missing iounmap() on error in vfio_platform_amdxgbe_reset() Yang Yingliang
2021-05-18 21:46 ` Alex Williamson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.