From 8e8f71952be7cf99fe2abd0bb5c2d11df0b8e132 Mon Sep 17 00:00:00 2001 From: Aditya Sathish Date: Wed, 22 May 2019 12:38:49 +0530 Subject: [PATCH] qcacmn: Add NULL check while iterating sgl entries __qdf_dma_get_sgtable_dma_addr() iterates through sgl entries without appropriately checking for NULL pointers before attempting to access them. Fix the above-mentioned issue by adding a NULL check before access. Change-Id: I7456db834f71b9b5cf3cb254526177b9fdcee664 CRs-Fixed: 2448239 --- qdf/linux/src/i_qdf_mem.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qdf/linux/src/i_qdf_mem.h b/qdf/linux/src/i_qdf_mem.h index acf9bbe93ab0..6556865bb7a6 100644 --- a/qdf/linux/src/i_qdf_mem.h +++ b/qdf/linux/src/i_qdf_mem.h @@ -288,8 +288,12 @@ __qdf_dma_get_sgtable_dma_addr(struct sg_table *sgt) struct scatterlist *sg; int i; - for_each_sg(sgt->sgl, sg, sgt->nents, i) + for_each_sg(sgt->sgl, sg, sgt->nents, i) { + if (!sg) + break; + sg->dma_address = sg_phys(sg); + } } /**