[PATCH vmmouse] Don't de-reference pMse if it hasn't been initialised yet

Peter Hutterer peter.hutterer at who-t.net
Sun Feb 10 21:30:54 PST 2013


If the device fails PreInit, UnInit is still called by pMse may be NULL.
Dereferencing it is a bad idea.

Regression introduced in 9acbedeb887cf8504fd2ca7195b19cff16e8eaf6

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
sorry, this escaped my testing before :(

 src/vmmouse.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/vmmouse.c b/src/vmmouse.c
index fb053c2..523f4fd 100644
--- a/src/vmmouse.c
+++ b/src/vmmouse.c
@@ -808,11 +808,13 @@ static void
 VMMouseUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 {
    MouseDevPtr pMse = pInfo->private;
-   VMMousePrivPtr mPriv = (VMMousePrivPtr)pMse->mousePriv;
 
    xf86Msg(X_INFO, "VMWARE(0): VMMouseUnInit\n");
 
-   free(mPriv);
+   if (pMse) {
+       VMMousePrivPtr mPriv = (VMMousePrivPtr)pMse->mousePriv;
+       free(mPriv);
+   }
 
    xf86DeleteInput(pInfo, flags);
 }
-- 
1.8.1.2



More information about the xorg-devel mailing list