dmaengine: idxd: Fix leaking event log memory
PATCH 1/1 dmaengine: idxd: Fix leaking event log memory
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit ee66bc29578391c9b48523dc9119af67bd5c7c0f ]
During the device remove process, the device is reset, causing the configuration registers to go back to their default state, which is zero. As the driver is checking if the event log support was enabled before deallocating, it will fail if a reset happened before.
Do not check if the support was enabled, the check for 'idxd->evl' being valid (only allocated if the HW capability is available) is enough.
--- drivers/dma/idxd/device.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/dma/idxd/device.c +0 -4
@@ -810,10 +810,6 @@ static void idxd_device_evl_free(struct idxd_device *idxd)struct device *dev = &idxd->pdev->dev;struct idxd_evl *evl = idxd->evl; - gencfg.bits =ioread32 (idxd->reg_base +IDXD_GENCFG_OFFSET ); -if (!gencfg.evl_en) -return ; -mutex_lock (&evl->lock); gencfg.evl_en =0 ;iowrite32 (gencfg.bits, idxd->reg_base +IDXD_GENCFG_OFFSET );
Signature · 1 line
2.43.0
Sasha Levin
maintainerdrivers/dma/idxd/device.c static void idxd_device_evl_free(struct idxd_device *idxd) · line 813
Quoted 9 lines · Wenshan Lan
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit
ee66bc29578391c9b48523dc9119af67bd5c7c0f]drivers/dma/idxd/device.c +0
-4- gencfg.bits =ioread32 (idxd->reg_base +IDXD_GENCFG_OFFSET ); -if (!gencfg.evl_en) -return ; -mutex_lock (&evl->lock);
This drops the only thing that protects no-evl-capable hardware (idxd->evl == NULL) from dereferencing evl in idxd_device_evl_free(). On 6.6, idxd_init_evl() returns 0 without allocating evl when hw.gen_cap.evl_support == 0, and idxd_device_evl_free() is still reachable in that path, so taking ee66bc29 alone will introduce a NULL deref on hardware without event-log support.
The required prerequisite is upstream commit 52d2edea0d63c ("dmaengine: idxd: Fix crash when the event log is disabled"), which adds the "if (!evl) return;" guard at the top of idxd_device_evl_free(). It landed as patch 2 of the same v3 series and is missing from 6.6.y.
Could you resend as a 2-patch series with 52d2edea0d63c as the prerequisite? Then I'm happy to queue both for 6.6.y.
--
Thanks,
Sasha
Quoted 17 lines · Sasha Levin
drivers/dma/idxd/device.c static void idxd_device_evl_free(struct idxd_device *idxd) · line 813
Quoted 9 lines · Wenshan Lan
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit
ee66bc29578391c9b48523dc9119af67bd5c7c0f]drivers/dma/idxd/device.c +0
-4- gencfg.bits =ioread32 (idxd->reg_base +IDXD_GENCFG_OFFSET ); -if (!gencfg.evl_en) -return ; -mutex_lock (&evl->lock);This drops the only thing that protects no-evl-capable hardware (
idxd->evl== NULL) from dereferencing evl inidxd_device_evl_free(). On 6.6,idxd_init_evl()returns 0 without allocating evl when hw.gen_cap.evl_support == 0, andidxd_device_evl_free()is still reachable in that path, so takingee66bc29alone will introduce a NULL deref on hardware without event-log support.
Quoted 7 lines
The required prerequisite is upstream commit
52d2edea0d63c("dmaengine: idxd: Fix crash when the event log is disabled"), which adds the "if (!evl) return;" guard at the top ofidxd_device_evl_free(). It landed as patch 2 of the same v3 series and is missing from 6.6.y.Could you resend as a 2-patch series with
52d2edea0d63cas the prerequisite? Then I'm happy to queue both for 6.6.y.
Thank you for your review. I will resend v2.
Wenshan Lan
Quoted 4 lines
--
Thanks,
Sasha