public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] VMCI: Fix NULL pointer dereference on context ptr
@ 2020-03-23  8:22 Xiyu Yang
  2020-03-23  8:52 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Xiyu Yang @ 2020-03-23  8:22 UTC (permalink / raw)
  To: Arnd Bergmann, Greg Kroah-Hartman, Alexios Zavras, Allison Randal,
	Adit Ranadive, Jorgen Hansen, Thomas Gleixner, Vishnu DASA,
	Xiyu Yang, linux-kernel
  Cc: yuanxzhang, kjlu, Xin Tan

A NULL vmci_ctx object may pass to vmci_ctx_put() from its callers.
Add a NULL check to prevent NULL pointer dereference.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
---
 drivers/misc/vmw_vmci/vmci_context.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/vmw_vmci/vmci_context.c b/drivers/misc/vmw_vmci/vmci_context.c
index 16695366ec92..2f4963ab51bd 100644
--- a/drivers/misc/vmw_vmci/vmci_context.c
+++ b/drivers/misc/vmw_vmci/vmci_context.c
@@ -494,7 +494,8 @@ static void ctx_free_ctx(struct kref *kref)
  */
 void vmci_ctx_put(struct vmci_ctx *context)
 {
-	kref_put(&context->kref, ctx_free_ctx);
+	if (context)
+		kref_put(&context->kref, ctx_free_ctx);
 }
 
 /*
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-29 12:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-23  8:22 [PATCH v2] VMCI: Fix NULL pointer dereference on context ptr Xiyu Yang
2020-03-23  8:52 ` Greg Kroah-Hartman
2020-03-23  9:16   ` Arnd Bergmann
2020-03-23 10:16     ` Jorgen Hansen
2020-03-29 12:08   ` Xiyu Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox