g_slist_alloc is only used to create a new entry in the list and it is not
needed to initialize the list (it actually inserted an empty item at the
beginning of the list).
Also use strdup to store a copy of the device name (+ cleanup code)
---
loader/driverdisk.c | 11 ++++-------
loader/loader.c | 7 +++++++
2 files changed, 11 insertions(+), 7 deletions(-)
- if ((ddDevice = g_slist_alloc())==NULL) {
- logMessage(ERROR, "Cannot allocate space for list of devices");
- return NULL;
- }
-
bIter = blkid_dev_iterate_begin(bCache);
blkid_dev_set_search(bIter, "LABEL", ddLabel);
while ((res = blkid_dev_next(bIter, &bDev)) == 0) {
bDev = blkid_verify(bCache, bDev);
if (!bDev)
continue;
+
+ char *devname = strdup(blkid_dev_devname(bDev));
logMessage(DEBUGLVL, "Adding driver disc %s to the list "
- "of available DDs.", blkid_dev_devname(bDev));
- ddDevice = g_slist_prepend(ddDevice, (gpointer)blkid_dev_devname(bDev));
+ "of available DDs.", devname);
+ ddDevice = g_slist_prepend(ddDevice, (gpointer)devname);
/* Freeing bDev is taken care of by the put cache call */
}
blkid_dev_iterate_end(bIter);
diff --git a/loader/loader.c b/loader/loader.c
index d8d5fd5..9bf7c2f 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -1971,12 +1971,19 @@ int main(int argc, char ** argv) {
dd = findDriverDiskByLabel();
dditer = dd;
while(dditer) {
+ /* load the DD */
if (loadDriverDiskFromPartition(&loaderData, (char*)(dditer->data))) {
logMessage(ERROR, "Automatic driver disk loader failed for %s.", (char*)(dditer->data));
}
else {
logMessage(INFO, "Automatic driver disk loader succeeded for %s.", (char*)(dditer->data));
}
+
+ /* clean the device record */
+ free((char*)(dditer->data));
+ dditer->data = NULL;
+
+ /* next DD */
dditer = g_slist_next(dditer);
}
g_slist_free(dd);
--
1.6.6
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
01-19-2010, 07:16 PM
Hans de Goede
Fix SIGSEGV in dlabel feature (#556390)
Ack.
On 01/19/2010 04:12 PM, Martin Sivak wrote:
g_slist_alloc is only used to create a new entry in the list and it is not
needed to initialize the list (it actually inserted an empty item at the
beginning of the list).
Also use strdup to store a copy of the device name (+ cleanup code)
---
loader/driverdisk.c | 11 ++++-------
loader/loader.c | 7 +++++++
2 files changed, 11 insertions(+), 7 deletions(-)