Skip to content

Commit 1ffc6f3

Browse files
tititiou36vinodkoul
authored andcommitted
dmaengine: dw-edma: Fix return value check for dma_set_mask_and_coherent()
The commit in the Fixes: tag has changed the logic of the code and now it is likely that the probe will return an early success (0), even if not completely executed. This should lead to a crash or similar issue later on when the code accesses to some never allocated resources. Change the '!err' into a 'err' when checking if 'dma_set_mask_and_coherent()' has failed or not. While at it, simplify the code and remove the "can't success code" related to 32 DMA mask. As stated in [1], 'dma_set_mask_and_coherent(DMA_BIT_MASK(64))' can't fail if 'dev->dma_mask' is non-NULL. And if it is NULL, it would fail for the same reason when tried with DMA_BIT_MASK(32). [1]: https://lkml.org/lkml/2021/6/7/398 Fixes: ecb8c88 ("dmaengine: dw-edma-pcie: switch from 'pci_' to 'dma_' API") Signed-off-by: Christophe JAILLET <[email protected]> Link: https://lore.kernel.org/r/935fbb40ae930c5fe87482a41dcb73abf2257973.1636492127.git.christophe.jaillet@wanadoo.fr Signed-off-by: Vinod Koul <[email protected]>
1 parent 8856330 commit 1ffc6f3

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

drivers/dma/dw-edma/dw-edma-pcie.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,9 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
187187

188188
/* DMA configuration */
189189
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
190-
if (!err) {
190+
if (err) {
191191
pci_err(pdev, "DMA mask 64 set failed\n");
192192
return err;
193-
} else {
194-
pci_err(pdev, "DMA mask 64 set failed\n");
195-
196-
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
197-
if (err) {
198-
pci_err(pdev, "DMA mask 32 set failed\n");
199-
return err;
200-
}
201193
}
202194

203195
/* Data structure allocation */

0 commit comments

Comments
 (0)