FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CRUX > CRUX

 
 
LinkBack Thread Tools
 
Old 01-19-2010, 02:12 PM
Martin Sivak
 
Default Fix SIGSEGV in dlabel feature (#556390)

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(-)

diff --git a/loader/driverdisk.c b/loader/driverdisk.c
index e2acbc8..769d075 100644
--- a/loader/driverdisk.c
+++ b/loader/driverdisk.c
@@ -841,20 +841,17 @@ GSList* findDriverDiskByLabel(void)
return NULL;
}

- 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
 
Old 01-19-2010, 07:16 PM
Hans de Goede
 
Default 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(-)

diff --git a/loader/driverdisk.c b/loader/driverdisk.c
index e2acbc8..769d075 100644
--- a/loader/driverdisk.c
+++ b/loader/driverdisk.c
@@ -841,20 +841,17 @@ GSList* findDriverDiskByLabel(void)
return NULL;
}

- 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);


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 02:09 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org