Don't leak mtdev data
This commit is contained in:
parent
61734f1224
commit
cdc48c2c0e
112
0001-Release-mtdev-data-whenever-we-close-the-fd.patch
Normal file
112
0001-Release-mtdev-data-whenever-we-close-the-fd.patch
Normal file
@ -0,0 +1,112 @@
|
||||
From ac5173163d7d1e18d47630a397ece0f26b2568c8 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Hutterer <peter.hutterer@who-t.net>
|
||||
Date: Mon, 28 May 2012 09:08:43 +1000
|
||||
Subject: [PATCH evdev] Release mtdev data whenever we close the fd
|
||||
|
||||
Add a new EvdevCloseDevice() function to unify this.
|
||||
We used to leak data
|
||||
- PreInit allocates mtdev, but nothing except one error path released it.
|
||||
- each DEVICE_ON re-allocates mtdev but it is never released
|
||||
|
||||
Reported-by: Zdenek Kabelac <zdenek.kabelac@gmail.com>
|
||||
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
||||
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
|
||||
---
|
||||
src/evdev.c | 38 +++++++++++++++++++++++++-------------
|
||||
1 file changed, 25 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/evdev.c b/src/evdev.c
|
||||
index 055bc3f..fb44c37 100644
|
||||
--- a/src/evdev.c
|
||||
+++ b/src/evdev.c
|
||||
@@ -119,6 +119,7 @@ static int EvdevSwitchMode(ClientPtr client, DeviceIntPtr device, int mode);
|
||||
static BOOL EvdevGrabDevice(InputInfoPtr pInfo, int grab, int ungrab);
|
||||
static void EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4]);
|
||||
static int EvdevOpenDevice(InputInfoPtr pInfo);
|
||||
+static void EvdevCloseDevice(InputInfoPtr pInfo);
|
||||
|
||||
static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms);
|
||||
static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms);
|
||||
@@ -1108,8 +1109,7 @@ EvdevReadInput(InputInfoPtr pInfo)
|
||||
EvdevMBEmuFinalize(pInfo);
|
||||
Evdev3BEmuFinalize(pInfo);
|
||||
xf86RemoveEnabledDevice(pInfo);
|
||||
- close(pInfo->fd);
|
||||
- pInfo->fd = -1;
|
||||
+ EvdevCloseDevice(pInfo);
|
||||
} else if (errno != EAGAIN)
|
||||
{
|
||||
/* We use X_NONE here because it doesn't alloc */
|
||||
@@ -1866,8 +1866,7 @@ EvdevProc(DeviceIntPtr device, int what)
|
||||
{
|
||||
EvdevGrabDevice(pInfo, 0, 1);
|
||||
xf86RemoveEnabledDevice(pInfo);
|
||||
- close(pInfo->fd);
|
||||
- pInfo->fd = -1;
|
||||
+ EvdevCloseDevice(pInfo);
|
||||
}
|
||||
pEvdev->min_maj = 0;
|
||||
pEvdev->flags &= ~EVDEV_INITIALIZED;
|
||||
@@ -1876,10 +1875,7 @@ EvdevProc(DeviceIntPtr device, int what)
|
||||
|
||||
case DEVICE_CLOSE:
|
||||
xf86IDrvMsg(pInfo, X_INFO, "Close\n");
|
||||
- if (pInfo->fd != -1) {
|
||||
- close(pInfo->fd);
|
||||
- pInfo->fd = -1;
|
||||
- }
|
||||
+ EvdevCloseDevice(pInfo);
|
||||
EvdevFreeMasks(pEvdev);
|
||||
EvdevRemoveDevice(pInfo);
|
||||
pEvdev->min_maj = 0;
|
||||
@@ -2368,17 +2364,34 @@ EvdevOpenDevice(InputInfoPtr pInfo)
|
||||
if (EvdevIsDuplicate(pInfo))
|
||||
{
|
||||
xf86IDrvMsg(pInfo, X_WARNING, "device file is duplicate. Ignoring.\n");
|
||||
+ EvdevCloseDevice(pInfo);
|
||||
+ return BadMatch;
|
||||
+ }
|
||||
+
|
||||
+ return Success;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+EvdevCloseDevice(InputInfoPtr pInfo)
|
||||
+{
|
||||
+ EvdevPtr pEvdev = pInfo->private;
|
||||
+ if (pInfo->fd >= 0)
|
||||
+ {
|
||||
close(pInfo->fd);
|
||||
+ pInfo->fd = -1;
|
||||
+ }
|
||||
+
|
||||
#ifdef MULTITOUCH
|
||||
+ if (pEvdev->mtdev)
|
||||
+ {
|
||||
mtdev_close_delete(pEvdev->mtdev);
|
||||
pEvdev->mtdev = NULL;
|
||||
-#endif
|
||||
- return BadMatch;
|
||||
}
|
||||
+#endif
|
||||
|
||||
- return Success;
|
||||
}
|
||||
|
||||
+
|
||||
static void
|
||||
EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
|
||||
{
|
||||
@@ -2459,8 +2472,7 @@ EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
|
||||
return Success;
|
||||
|
||||
error:
|
||||
- if (pInfo->fd >= 0)
|
||||
- close(pInfo->fd);
|
||||
+ EvdevCloseDevice(pInfo);
|
||||
return rc;
|
||||
}
|
||||
|
||||
--
|
||||
1.7.10.4
|
||||
|
@ -8,7 +8,7 @@
|
||||
Summary: Xorg X11 evdev input driver
|
||||
Name: xorg-x11-drv-evdev
|
||||
Version: 2.7.0
|
||||
Release: 3%{?gitdate:.%{gitdate}git%{gitversion}}%{dist}
|
||||
Release: 4%{?gitdate:.%{gitdate}git%{gitversion}}%{dist}
|
||||
URL: http://www.x.org
|
||||
License: MIT
|
||||
Group: User Interface/X Hardware Support
|
||||
@ -24,6 +24,8 @@ Source0: ftp://ftp.x.org/pub/individual/driver/%{tarball}-%{version}.tar.bz2
|
||||
Patch01: 0001-Fix-inverted-horizontal-scroll-46205.patch
|
||||
# Bug 805902 - Scrollwheels on tablets are broken
|
||||
Patch02: 0001-Allow-relative-scroll-valuators-on-absolute-devices.patch
|
||||
# Don't leak mtdev data
|
||||
Patch03: 0001-Release-mtdev-data-whenever-we-close-the-fd.patch
|
||||
|
||||
ExcludeArch: s390 s390x %{?rhel:ppc ppc64}
|
||||
|
||||
@ -85,6 +87,9 @@ X.Org X11 evdev input driver development files.
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Jul 04 2012 Peter Hutterer <peter.hutterer@redhat.com> 2.7.0-4
|
||||
- Don't leak mtdev data
|
||||
|
||||
* Thu Apr 05 2012 Adam Jackson <ajax@redhat.com> - 2.7.0-3
|
||||
- RHEL arch exclude updates
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user