summaryrefslogtreecommitdiffstats
path: root/abs/core/hal/dbus-error-init.patch
blob: fb3ad020a7d56a0b65eef12809a7a7e5db5f8ff3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
From dcb2829b8eff61463b0869614ddb07b1c86cecaa Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Date: Wed, 30 Dec 2009 11:42:52 +0000
Subject: linux/probe-input: don't use error prio init

it may happen in the out: case that LIBHAL_FREE_DBUS_ERROR (&error) is
called before the error structure is initialized via
dbus_error_init (&error). This could lead to a segfault during startup
as seen in dmesg:

|Intel AES-NI instructions are not detected.
|padlock: VIA PadLock not detected.
|hald-probe-inpu[1793]: segfault at 2 ip 00007f656fb68969 sp 00007fff39eeb950 error 4 in libc-2.10.2.so[7f656faf3000+14a000]
|hald-probe-inpu[1796]: segfault at 2 ip 00007fa2c3293969 sp 00007fffd92a5dd0 error 4 in libc-2.10.2.so[7fa2c321e000+14a000]
|hald-probe-inpu[1797]: segfault at 2 ip 00007f1d08ba2969 sp 00007fff34244e30 error 4 in libc-2.10.2.so[7f1d08b2d000+14a000]
|hald-probe-inpu[1799]: segfault at 2 ip 00007f35c0e3d969 sp 00007fffe5ec7ee0 error 4 in libc-2.10.2.so[7f35c0dc8000+14a000]
|hald-probe-inpu[1800]: segfault at 2 ip 00007f931c556969 sp 00007fffe1825b60 error 4 in libc-2.10.2.so[7f931c4e1000+14a000]
|hald-probe-inpu[1801]: segfault at 2 ip 00007f5156d9a969 sp 00007fff4e620af0 error 4 in libc-2.10.2.so[7f5156d25000+14a000]
|RPC: Registered udp transport module.
|RPC: Registered tcp transport module.

What I run into seems to be reported as Debian #562068 [0]. This patch
makes the segfault go away on my machine.

[0] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=562068

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
---
diff --git a/hald/linux/probing/probe-input.c b/hald/linux/probing/probe-input.c
index 94e9929..cad47d3 100644
--- a/hald/linux/probing/probe-input.c
+++ b/hald/linux/probing/probe-input.c
@@ -70,6 +70,7 @@ main (int argc, char *argv[])
 	fd = -1;
 
 	setup_logger ();
+	dbus_error_init (&error);
 
 	button_type = getenv ("HAL_PROP_BUTTON_TYPE");
 	if (button_type == NULL)
@@ -96,7 +97,6 @@ main (int argc, char *argv[])
 	if (udi == NULL)
 		goto out;
 
-	dbus_error_init (&error);
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL)
 		goto out;
 
--
cgit v0.8.3-6-g21f6
From baa61a879985d63f549854518ef14efd40e62e8c Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 24 Feb 2010 16:19:28 +0000
Subject: Make sure dbus_error_init() is called before LIBHAL_FREE_DBUS_ERROR()

If dbus_error_init() is not called before LIBHAL_FREE_DBUS_ERROR() is
called on that error, then it is uninitialized and may segfault.  This
means that dbus_error_init() must be called before any "goto out" if
"out:" calls LIBHAL_FREE_DBUS_ERROR().

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
---
diff --git a/hald/linux/probing/probe-hiddev.c b/hald/linux/probing/probe-hiddev.c
index 45d2084..bffc040 100644
--- a/hald/linux/probing/probe-hiddev.c
+++ b/hald/linux/probing/probe-hiddev.c
@@ -57,11 +57,12 @@ main (int argc, char *argv[])
 	/* assume failure */
 	ret = 1;
 
+	dbus_error_init (&error);
+
 	udi = getenv ("UDI");
 	if (udi == NULL)
 		goto out;
 
-	dbus_error_init (&error);
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL)
 		goto out;
 
diff --git a/hald/linux/probing/probe-ieee1394-unit.c b/hald/linux/probing/probe-ieee1394-unit.c
index 70b0f86..aaa92e2 100644
--- a/hald/linux/probing/probe-ieee1394-unit.c
+++ b/hald/linux/probing/probe-ieee1394-unit.c
@@ -388,6 +388,8 @@ int main (int argc, char *argv[])
 
 	setup_logger ();
 
+	dbus_error_init (&error);
+
 	udi = getenv ("UDI");
 	if (udi == NULL)
 		goto out;
@@ -396,7 +398,6 @@ int main (int argc, char *argv[])
 	if (ieee1394_udi == NULL)
 		goto out;
 
-	dbus_error_init (&error);
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL)
 		goto out;
 
diff --git a/hald/linux/probing/probe-net-bluetooth.c b/hald/linux/probing/probe-net-bluetooth.c
index 0b1b912..e911eea 100644
--- a/hald/linux/probing/probe-net-bluetooth.c
+++ b/hald/linux/probing/probe-net-bluetooth.c
@@ -141,6 +141,8 @@ main (int argc, char *argv[])
 	DBusMessage *reply = NULL;
 	DBusError error;
 
+	dbus_error_init (&error);
+
 	udi = getenv ("UDI");
 	if (udi == NULL)
 		goto out;
@@ -151,8 +153,6 @@ main (int argc, char *argv[])
 
 	HAL_INFO (("Investigating '%s'", iface));
 
-	dbus_error_init (&error);
-
 	if ((conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error)) == NULL)
 		goto out;
 
diff --git a/hald/linux/probing/probe-printer.c b/hald/linux/probing/probe-printer.c
index 91ed7bc..7c6d1c6 100644
--- a/hald/linux/probing/probe-printer.c
+++ b/hald/linux/probing/probe-printer.c
@@ -66,6 +66,8 @@ main (int argc, char *argv[])
 	ret = 1;
 
 	setup_logger ();
+
+	dbus_error_init (&error);
 	
 	udi = getenv ("UDI");
 	if (udi == NULL) {
@@ -73,7 +75,6 @@ main (int argc, char *argv[])
 		goto out;
 	}
 
-	dbus_error_init (&error);
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
 		HAL_ERROR (("ctx init failed"));
 		goto out;
diff --git a/hald/linux/probing/probe-smbios.c b/hald/linux/probing/probe-smbios.c
index 0bc9689..15c0d4f 100644
--- a/hald/linux/probing/probe-smbios.c
+++ b/hald/linux/probing/probe-smbios.c
@@ -129,6 +129,8 @@ main (int argc, char *argv[])
 	ret = 1;
 
 	setup_logger ();
+
+	dbus_error_init (&error);
 	
 	udi = getenv ("UDI");
 	if (udi == NULL) {
@@ -136,7 +138,6 @@ main (int argc, char *argv[])
 		goto out;
 	}
 
-	dbus_error_init (&error);
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
 		HAL_ERROR (("ctx init failed"));
 		goto out;
diff --git a/hald/linux/probing/probe-storage.c b/hald/linux/probing/probe-storage.c
index 824a82e..dd524ca 100644
--- a/hald/linux/probing/probe-storage.c
+++ b/hald/linux/probing/probe-storage.c
@@ -109,6 +109,8 @@ main (int argc, char *argv[])
 	/* assume failure */
 	ret = 1;
 
+	dbus_error_init (&error);
+
 	if ((udi = getenv ("UDI")) == NULL)
 		goto out;
 	if ((device_file = getenv ("HAL_PROP_BLOCK_DEVICE")) == NULL)
@@ -127,7 +129,6 @@ main (int argc, char *argv[])
 	else
 		only_check_for_fs = FALSE;
 
-	dbus_error_init (&error);
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL)
 		goto out;
 
diff --git a/hald/linux/probing/probe-video4linux.c b/hald/linux/probing/probe-video4linux.c
index cf913c0..7bc13e8 100644
--- a/hald/linux/probing/probe-video4linux.c
+++ b/hald/linux/probing/probe-video4linux.c
@@ -58,6 +58,8 @@ main (int argc, char *argv[])
 
 	setup_logger ();
 
+	dbus_error_init (&error);
+
 	device_file = getenv ("HAL_PROP_VIDEO4LINUX_DEVICE");
 	if (device_file == NULL)
 		goto out;
@@ -66,7 +68,6 @@ main (int argc, char *argv[])
 	if (udi == NULL)
 		goto out;
 
-	dbus_error_init (&error);
 	ctx = libhal_ctx_init_direct (&error);
 	if (ctx == NULL)
 		goto out;
diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index 0de1b91..7268fff 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -318,6 +318,8 @@ main (int argc, char *argv[])
 	/* assume failure */
 	ret = 1;
 
+	dbus_error_init (&error);
+
 	if ((udi = getenv ("UDI")) == NULL)
 		goto out;
 	if ((device_file = getenv ("HAL_PROP_BLOCK_DEVICE")) == NULL)
@@ -346,7 +348,6 @@ main (int argc, char *argv[])
 
 	fsusage = getenv ("HAL_PROP_VOLUME_FSUSAGE");
 
-	dbus_error_init (&error);
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL)
 		goto out;
 
--
cgit v0.8.3-6-g21f6