msm: smem: initialize remote spinlock in smem_alloc2()
smem_alloc2() might be called before the remote spinlock is initialized.
This causes a null pointer dereference crash when an attempt to lock
the spinlock is made. Unlike, smem_alloc(), smem_alloc2() modifies shared
memory structures, so locking the spinlock is required under all conditions
to prevent corruption.
Fix the crash by attempting to initialize the spinlock if it is not already
initalized.
Change-Id: Ie943b3dc470648b5948e6d72bc77262176359f2c
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
diff --git a/arch/arm/mach-msm/smd.c b/arch/arm/mach-msm/smd.c
index 1945651..a177593 100644
--- a/arch/arm/mach-msm/smd.c
+++ b/arch/arm/mach-msm/smd.c
@@ -3939,12 +3939,11 @@
}
registered = true;
- rc = remote_spin_lock_init(&remote_spinlock, SMEM_SPINLOCK_SMEM_ALLOC);
+ rc = init_smem_remote_spinlock();
if (rc) {
pr_err("%s: remote spinlock init failed %d\n", __func__, rc);
return rc;
}
- spinlocks_initialized = 1;
rc = platform_driver_register(&msm_smd_driver);
if (rc) {