From 32edbeece84e2549cc30067f67d276488d4a000a Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Fri, 19 Feb 2016 09:46:12 +0530 Subject: [PATCH] msm: iommu: Fix NULL pointer dereference Fix the following NULL pointer dereference issue. Pointer '__p' returned from call to function 'smem_alloc' at line 84 may be NULL and will be dereferenced at line 85. drivers/iommu/msm_iommu.c +85 | _msm_iommu_remote_spin_lock_init() Change-Id: I3549e8dc6cb6b13518ced7d28186da74667c1cb6 Signed-off-by: Binoy Jayan --- drivers/iommu/msm_iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c index 2835f6d916ed..0e561cabbfc0 100644 --- a/drivers/iommu/msm_iommu.c +++ b/drivers/iommu/msm_iommu.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved. * +/* Copyright (c) 2010-2012, 2016, 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 * only version 2 as published by the Free Software Foundation. @@ -87,8 +88,10 @@ static struct msm_iommu_remote_lock msm_iommu_remote_lock; static void _msm_iommu_remote_spin_lock_init(void) { msm_iommu_remote_lock.lock = smem_alloc(SMEM_SPINLOCK_ARRAY, 32); - memset(msm_iommu_remote_lock.lock, 0, + if (msm_iommu_remote_lock.lock) { + memset(msm_iommu_remote_lock.lock, 0, sizeof(*msm_iommu_remote_lock.lock)); + } } void msm_iommu_remote_p0_spin_lock(void)