Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3469688ybb; Mon, 23 Mar 2020 01:28:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsJUTSHvd6jQCQsclILSdez1+3T8BYebCQl9m2679LX23Ma0GPqPZOGBuWs/M7expcIGoyo X-Received: by 2002:a9d:220e:: with SMTP id o14mr15839039ota.88.1584952138059; Mon, 23 Mar 2020 01:28:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584952138; cv=none; d=google.com; s=arc-20160816; b=lrsdr5yt8Jg6/A9bZniUl02ZdaTlJyePFJr/s6svRk4gPtBeiqxaJ2xapJujjWVrxk hPBC67pIhQ9JDvXQKeTcIZwYAeQnnN6OGVUfFyWoLdYHD3bB9wtTBgLWtrmovBbSG7Wh SadOFJnbk9rvxeDozI7cBeP3wy8mlytEydPcxFXsI7aZXn4XMNP8AEYJvbZQ3cHx9xn0 uk5/M71f/Oxh1zPtA837khq978HIpkO/XBUxD20yvTmYsdMrS9noTTNFSOjFoU0RtxTT VjRLMPRNMnvxTvxNsgz37iqKRHjl2Whblk/WWYsAzVU3SBT/HXZCBvU194WeFS5/EE17 wzpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=YK7M3T07KPrhL/NPCPIWesFYpHhaKJkSLesc5rwLQhk=; b=rCbDu7rfeAAtaJdYa4z0HCUt76WT24J3XBKHna3kd/gi82+AnyJsaPYgwWS2qFBd6S qIZ7ajgNxbyBDViAmGEjpKiXcsOfgOyiV7bwvJ3mePwYNZwdXe0kWtOC+VevqSVXnhxG 57PP6ntsjNXZGarF/eRLR764nQdh0daUwg1U9jGtk0y3iU6aFqhAL8AUEygDnRac9zSB 8AOUXQmwpmpSic1h9QTzp8Apa52jpY0OwrHcFjG6ELs5iPrB4lntV76QTigcotA2qLGy 0/39rcDGBLP7Q8LhqbgD0YivBc4UFjZOno5oc9jrygYMYvbtNfzsIPUQUVwUJoLBB2N1 +DdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e24si3087266otk.203.2020.03.23.01.28.46; Mon, 23 Mar 2020 01:28:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727595AbgCWI23 (ORCPT + 99 others); Mon, 23 Mar 2020 04:28:29 -0400 Received: from mail.fudan.edu.cn ([202.120.224.10]:50384 "EHLO fudan.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727544AbgCWI22 (ORCPT ); Mon, 23 Mar 2020 04:28:28 -0400 Received: from localhost.localdomain (unknown [120.229.255.251]) by app1 (Coremail) with SMTP id XAUFCgCXnysVc3he4fcPAA--.9465S3; Mon, 23 Mar 2020 16:28:08 +0800 (CST) From: Xiyu Yang To: Arnd Bergmann , Greg Kroah-Hartman , Alexios Zavras , Allison Randal , Adit Ranadive , Jorgen Hansen , Thomas Gleixner , Vishnu DASA , Xiyu Yang , linux-kernel@vger.kernel.org Cc: yuanxzhang@fudan.edu.cn, kjlu@umn.edu, Xin Tan Subject: [PATCH v2] VMCI: Fix NULL pointer dereference on context ptr Date: Mon, 23 Mar 2020 16:22:33 +0800 Message-Id: <1584951832-120773-1-git-send-email-xiyuyang19@fudan.edu.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: XAUFCgCXnysVc3he4fcPAA--.9465S3 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pf9x0JUQZ23UUUUU= X-CM-SenderInfo: irzsiiysuqikmy6i3vldqovvfxof0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Xin Tan --- 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