diff options
| author | Arun Kumar Neelakantam <aneela@codeaurora.org> | 2018-03-16 16:30:32 +0530 |
|---|---|---|
| committer | celtare21 <celtare21@gmail.com> | 2019-08-24 19:00:02 +0000 |
| commit | 682c50341b90dde22792e6ec905767dc0df47799 (patch) | |
| tree | b3b488df756070c7a1ea6af4e60cb154ef383164 | |
| parent | 6bf7497cf2f9260cd1d29c255b99b223434f6ebb (diff) | |
soc: qcom: msm_smd: check for NULL pointer and return
Check for NULL pointer is present in WARN_ON() which prints message
and continue the execution.
Check and return the execution flow to avoid the NULL pointer
access.
CRs-Fixed: 2207243
Change-Id: I7d73762f3ead06afb97ddf762d9ea7f3fe466d26
[celtare21: Also swap BUG for WARN]
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
| -rw-r--r-- | drivers/soc/qcom/msm_smd.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/soc/qcom/msm_smd.c b/drivers/soc/qcom/msm_smd.c index 70cf65ec7ac4..73668f0d6c7a 100644 --- a/drivers/soc/qcom/msm_smd.c +++ b/drivers/soc/qcom/msm_smd.c @@ -1,7 +1,7 @@ /* drivers/soc/qcom/msm_smd.c * * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2008-2016, The Linux Foundation. All rights reserved. + * Copyright (c) 2008-2017, 2018, The Linux Foundation. All rights reserved. * Author: Brian Swetland <swetland@google.com> * * This software is licensed under the terms of the GNU General Public @@ -270,11 +270,12 @@ static void *smd_memcpy32_to_fifo(void *dest, const void *src, size_t num_bytes) uint32_t *dest_local = (uint32_t *)dest; uint32_t *src_local = (uint32_t *)src; - BUG_ON(num_bytes & SMD_FIFO_ADDR_ALIGN_BYTES); - BUG_ON(!dest_local || - ((uintptr_t)dest_local & SMD_FIFO_ADDR_ALIGN_BYTES)); - BUG_ON(!src_local || - ((uintptr_t)src_local & SMD_FIFO_ADDR_ALIGN_BYTES)); + if (WARN_ON(!dest_local || !src_local)) + return dest; + WARN_ON(num_bytes & SMD_FIFO_ADDR_ALIGN_BYTES); + WARN_ON(((uintptr_t)dest_local & SMD_FIFO_ADDR_ALIGN_BYTES)); + WARN_ON(((uintptr_t)src_local & SMD_FIFO_ADDR_ALIGN_BYTES)); + num_bytes /= sizeof(uint32_t); while (num_bytes--) @@ -302,11 +303,12 @@ static void *smd_memcpy32_from_fifo(void *dest, const void *src, uint32_t *dest_local = (uint32_t *)dest; uint32_t *src_local = (uint32_t *)src; - BUG_ON(num_bytes & SMD_FIFO_ADDR_ALIGN_BYTES); - BUG_ON(!dest_local || - ((uintptr_t)dest_local & SMD_FIFO_ADDR_ALIGN_BYTES)); - BUG_ON(!src_local || - ((uintptr_t)src_local & SMD_FIFO_ADDR_ALIGN_BYTES)); + if (WARN_ON(!dest_local || !src_local)) + return dest; + WARN_ON(num_bytes & SMD_FIFO_ADDR_ALIGN_BYTES); + WARN_ON(((uintptr_t)dest_local & SMD_FIFO_ADDR_ALIGN_BYTES)); + WARN_ON(((uintptr_t)src_local & SMD_FIFO_ADDR_ALIGN_BYTES)); + num_bytes /= sizeof(uint32_t); while (num_bytes--) |
