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

This commit is contained in:
Daniel Drake 2011-11-28 08:36:39 -06:00
parent 137f6c5b50
commit dd52719b75
2 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,48 @@
From a798395a1bfd9d06d40e2d8d14377a156c94429a Mon Sep 17 00:00:00 2001
From: Daniel Drake <dsd@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@laptop.org>
Reviewed-by: Alan Coopersmith <alan.coopersmith@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

View File

@ -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@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@redhat.com> 0.12.902-1
- libpciaccess 0.12.902