Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56ab569c authored by Shrey Vijay's avatar Shrey Vijay
Browse files

i2c-msm-v2: Add NULL pointer check for DMA descriptor



Add NULL pointer check for RX/TX DMA descriptors to avoid
NULL dereference.

Change-Id: I71443204e79eb1afc37a6b312cf4aa9adcaa22c6
Signed-off-by: default avatarShrey Vijay <shreyv@codeaurora.org>
parent 892b3aa7
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1274,10 +1274,10 @@ static int i2c_msm_dma_xfer_process(struct i2c_msm_ctrl *ctrl)
						tx->dir,
						(SPS_IOVEC_FLAG_EOT |
							SPS_IOVEC_FLAG_NWD));
	if (dma_desc_tx < 0) {
	if (IS_ERR_OR_NULL(dma_desc_tx)) {
		dev_err(ctrl->dev, "error dmaengine_prep_slave_sg tx:%ld\n",
							PTR_ERR(dma_desc_tx));
		ret = PTR_ERR(dma_desc_tx);
		ret = dma_desc_tx ? PTR_ERR(dma_desc_tx) : -ENOMEM;
		goto dma_xfer_end;
	}

@@ -1292,11 +1292,11 @@ static int i2c_msm_dma_xfer_process(struct i2c_msm_ctrl *ctrl)
					sg_rx_itr - sg_rx, rx->dir,
					(SPS_IOVEC_FLAG_EOT |
							SPS_IOVEC_FLAG_NWD));
	if (dma_desc_rx < 0) {
	if (IS_ERR_OR_NULL(dma_desc_rx)) {
		dev_err(ctrl->dev,
			"error dmaengine_prep_slave_sg rx:%ld\n",
						PTR_ERR(dma_desc_rx));
		ret = PTR_ERR(dma_desc_rx);
		ret = dma_desc_rx ? PTR_ERR(dma_desc_rx) : -ENOMEM;
		goto dma_xfer_end;
	}