diff mbox series

misc: fastrpc: Check for error num after setting mask

Message ID 20220106023234.2550800-1-jiasheng@iscas.ac.cn (mailing list archive)
State New, archived
Headers show
Series misc: fastrpc: Check for error num after setting mask | expand

Commit Message

Jiasheng Jiang Jan. 6, 2022, 2:32 a.m. UTC
Because of the possible failure of the dma_supported(), the
dma_set_mask_and_coherent() may return error num.
Therefore, it should be better to check it and return the error if
fails.

Fixes: f6f9279f2bf0 ("misc: fastrpc: Add Qualcomm fastrpc basic driver model")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/misc/fastrpc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index beda610e6b30..dd1c4a75bb1d 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1644,7 +1644,12 @@  static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
 	kref_init(&data->refcount);
 
 	dev_set_drvdata(&rpdev->dev, data);
-	dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32));
+	err = dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32));
+	if (err) {
+		kfree(data);
+		return err;
+	}
+
 	INIT_LIST_HEAD(&data->users);
 	spin_lock_init(&data->lock);
 	idr_init(&data->ctx_idr);