Repaired SIGSEGV caused by releasing ungrabbed drive after mere bus scan

This commit is contained in:
Thomas Schmitt 2006-08-30 12:23:01 +00:00
parent 96466c3be1
commit 24ad08b9ad
1 changed files with 15 additions and 5 deletions

View File

@ -68,6 +68,10 @@ static struct burn_drive_info *drives;
friendly to the users of other drives on those systems. Beware. */ friendly to the users of other drives on those systems. Beware. */
static unsigned int n_drives; static unsigned int n_drives;
/** This variable indicates wether the drive is grabbed and must be
finally released */
static int drive_is_grabbed = 0;
/** Wether to burn for real or to *try* to simulate a burn */ /** Wether to burn for real or to *try* to simulate a burn */
static int simulate_burn = Burniso_try_to_simulatE ; static int simulate_burn = Burniso_try_to_simulatE ;
@ -119,8 +123,10 @@ int burn_app_aquire_by_adr(char *drive_adr)
ret = burn_drive_scan_and_grab(&drives,drive_adr,1); ret = burn_drive_scan_and_grab(&drives,drive_adr,1);
if (ret <= 0) if (ret <= 0)
printf("Failed\n"); printf("Failed\n");
else else {
printf("done\n"); printf("done\n");
drive_is_grabbed = 1;
}
return ret; return ret;
} }
@ -295,11 +301,14 @@ int burn_app_regrab(struct burn_drive *drive) {
int ret; int ret;
printf("Releasing and regrabbing drive ...\n"); printf("Releasing and regrabbing drive ...\n");
burn_drive_release(drive, 0); if (drive_is_grabbed)
burn_drive_release(drive, 0);
drive_is_grabbed = 0;
ret = burn_drive_grab(drive, 0); ret = burn_drive_grab(drive, 0);
if (ret != 0) if (ret != 0) {
drive_is_grabbed = 1;
printf("done\n"); printf("done\n");
else } else
printf("Failed\n"); printf("Failed\n");
return !!ret; return !!ret;
} }
@ -568,7 +577,8 @@ int main(int argc, char **argv)
} }
ret = 0; ret = 0;
release_drive:; release_drive:;
burn_drive_release(drives[driveno].drive, 0); if(drive_is_grabbed)
burn_drive_release(drives[driveno].drive, 0);
finish_libburn:; finish_libburn:;
/* This app does not bother to know about exact scan state. /* This app does not bother to know about exact scan state.