[libpciaccess] add upstream fix to fix X crash on OLPC XO-1.5

Daniel Drake dsd at fedoraproject.org
Mon Nov 28 14:41:24 UTC 2011


commit dd52719b759157f991cad0d066aef4d7871b5b90
Author: Daniel Drake <dsd at laptop.org>
Date:   Mon Nov 28 08:36:39 2011 -0600

    add upstream fix to fix X crash on OLPC XO-1.5

 libpciaccess-ios-free.patch |   48 +++++++++++++++++++++++++++++++++++++++++++
 libpciaccess.spec           |    7 +++++-
 2 files changed, 54 insertions(+), 1 deletions(-)
---
diff --git a/libpciaccess-ios-free.patch b/libpciaccess-ios-free.patch
new file mode 100644
index 0000000..13edff5
--- /dev/null
+++ b/libpciaccess-ios-free.patch
@@ -0,0 +1,48 @@
+From a798395a1bfd9d06d40e2d8d14377a156c94429a Mon Sep 17 00:00:00 2001
+From: Daniel Drake <dsd at laptop.org>
+Date: Fri, 25 Nov 2011 12:28:48 -0600
+Subject: [PATCH] delete_io_handle: fix deletion of last handle
+
+When num_ios goes from 1 to 0, a realloc(ios, 0); call is made.
+This is equivalent to free(ios) and NULL is returned.
+
+However, the previous logic in the code incorrectly discards this NULL
+return value. When we next call new_io_handle(), realloc(ios, X) is
+called with "ios" pointing to freed memory. This causes glibc to abort.
+
+Correct this logic to detect the 1-to-0 case and handle it correctly.
+Other cases are unchanged; there is still value in checking the
+return value from realloc() as it also returns NULL on error.
+
+Signed-off-by: Daniel Drake <dsd at laptop.org>
+Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
+---
+ src/common_io.c |   11 ++++++++---
+ 1 files changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/src/common_io.c b/src/common_io.c
+index f1319f8..5b35e07 100644
+--- a/src/common_io.c
++++ b/src/common_io.c
+@@ -64,10 +64,15 @@ delete_io_handle(struct pci_io_handle *handle)
+         }
+     }
+ 
+-    new = realloc(ios, sizeof(struct pci_io_handle) * (num_ios - 1));
+-    if (new)
+-        ios = new;
+     num_ios--;
++    if (num_ios) {
++        new = realloc(ios, sizeof(struct pci_io_handle) * num_ios);
++        if (new)
++            ios = new;
++    } else {
++        free(ios);
++        ios = NULL;
++    }
+ }
+ 
+ _pci_hidden void
+-- 
+1.7.7.3
+
diff --git a/libpciaccess.spec b/libpciaccess.spec
index ce1fbe5..635e1dc 100644
--- a/libpciaccess.spec
+++ b/libpciaccess.spec
@@ -3,7 +3,7 @@
 
 Name:           libpciaccess
 Version:        0.12.902
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        PCI access library
 
 Group:          System Environment/Libraries
@@ -18,6 +18,7 @@ Source1:        make-libpciaccess-snapshot.sh
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 Patch2:		libpciaccess-rom-size.patch
+Patch3:		libpciaccess-ios-free.patch
 
 BuildRequires:  autoconf automake libtool pkgconfig xorg-x11-util-macros
 Requires:       hwdata
@@ -38,6 +39,7 @@ Development package for libpciaccess.
 %prep
 %setup -q -n %{name}-%{?gitdate:%{gitdate}}%{!?gitdate:%{version}}
 %patch2 -p1 -b .rom-size
+%patch3 -p1 -b .ios
 
 %build
 autoreconf -v --install
@@ -68,6 +70,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/pkgconfig/pciaccess.pc
 
 %changelog
+* Mon Nov 28 2011 Daniel Drake <dsd at laptop.org> 0.12.902-2
+- Add upstream patch to fix ios deletion; fixes X crash on OLPC XO-1.5
+
 * Wed Nov 09 2011 Adam Jackson <ajax at redhat.com> 0.12.902-1
 - libpciaccess 0.12.902
 


More information about the scm-commits mailing list