2020-03-16 16:21:07

by Xiyu Yang

[permalink] [raw]
Subject: [PATCH] VMCI: Fix dereference before NULL-check of context ptr

A NULL pointer can be returned by vmci_ctx_get(). Thus add a
corresponding check so that a NULL pointer dereference will
be avoided in vmci_ctx_put().

Signed-off-by: Xiyu Yang <[email protected]>
Signed-off-by: Xin Tan <[email protected]>
---
drivers/misc/vmw_vmci/vmci_queue_pair.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
index 032617101ebc..b6ba00ad9ec8 100644
--- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
+++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
@@ -1808,7 +1808,8 @@ static int qp_alloc_host_work(struct vmci_handle *handle,
pr_devel("queue pair broker failed to alloc (result=%d)\n",
result);
}
- vmci_ctx_put(context);
+ if (context)
+ vmci_ctx_put(context);
return result;
}

--
2.7.4


2020-03-16 17:46:55

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] VMCI: Fix dereference before NULL-check of context ptr

On Tue, Mar 17, 2020 at 12:18:33AM +0800, Xiyu Yang wrote:
> A NULL pointer can be returned by vmci_ctx_get(). Thus add a
> corresponding check so that a NULL pointer dereference will
> be avoided in vmci_ctx_put().
>
> Signed-off-by: Xiyu Yang <[email protected]>
> Signed-off-by: Xin Tan <[email protected]>
> ---
> drivers/misc/vmw_vmci/vmci_queue_pair.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)

You sent 2 different patches with the same subject, yet they did
different things :(

Please fix this up, make them unique, and send a patch series.

thanks,

greg k-h