Skip to contentSkip to conversation

dmaengine: qcom-adm: fix wrong sizeof config in slave_config

PATCH Applied Christian Marangi 4 participants 4 messages Sep 15, 2022 – Sep 29, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: qcom-adm: fix wrong sizeof config in slave_config

Fix broken slave_config function that uncorrectly compare the peripheral_size with the size of the config pointer instead of the size of the config struct. This cause the crci value to be ignored and cause a kernel panic on any slave that use adm driver.

To fix this, compare to the size of the struct and NOT the size of the pointer.

Fixes 03de6b273805 ("dmaengine: qcom-adm: stop abusing slave_id config")
Cc [email protected] # v5.17+
---
 drivers/dma/qcom/qcom_adm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/qcom/qcom_adm.c +1 -1
index facdacf8aede..c77d9de853de 100644
@@ -494,7 +494,7 @@ static int adm_slave_config(struct dma_chan *chan, struct dma_slave_config *cfg)
 
 	spin_lock_irqsave(&achan->vc.lock, flag);
 	memcpy(&achan->slave, cfg, sizeof(struct dma_slave_config));
-	if (cfg->peripheral_size == sizeof(config))
+	if (cfg->peripheral_size == sizeof(*config))
 		achan->crci = config->crci;
 	spin_unlock_irqrestore(&achan->vc.lock, flag);
 
Signature · 1 line
2.37.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Christian Marangi

Fix broken slave_config function that uncorrectly compare the peripheral_size with the size of the config pointer instead of the size of the config struct. This cause the crci value to be ignored and cause a kernel panic on any slave that use adm driver.

Quoted 6 lines

To fix this, compare to the size of the struct and NOT the size of the pointer.

Fixes 03de6b273805 ("dmaengine: qcom-adm: stop abusing slave_id config")
Cc [email protected] # v5.17+
Quoted 3 lines
---
 drivers/dma/qcom/qcom_adm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
With best wishes
Dmitry
Reviewed-by on v1 1/1
#2 lore raw
In reply to Christian Marangi
Quoted 11 lines · Christian Marangi

Fix broken slave_config function that uncorrectly compare the peripheral_size with the size of the config pointer instead of the size of the config struct. This cause the crci value to be ignored and cause a kernel panic on any slave that use adm driver.

To fix this, compare to the size of the struct and NOT the size of the pointer.

Fixes 03de6b273805 ("dmaengine: qcom-adm: stop abusing slave_id config")
Cc [email protected] # v5.17+

Thanks for the fix,

I guess this worked on 64-bit by accident, since both the pointer and the struct are 8 bytes, but it was clearly wrong and broke 32-bit.

Arnd

maintainer Applied
#3 lore raw
In reply to Christian Marangi
Quoted 7 lines · Christian Marangi

Fix broken slave_config function that uncorrectly compare the peripheral_size with the size of the config pointer instead of the size of the config struct. This cause the crci value to be ignored and cause a kernel panic on any slave that use adm driver.

To fix this, compare to the size of the struct and NOT the size of the pointer.

Applied, thanks

Signature · 1 line
~Vinod