Commit:     b47d2debf229469c78af4145ee7ad35a0f21b67f
Parent:     1d94cda04eb82feb87c932ac3d4aef1e9dc78a43
Author:     Jeff Dike <[EMAIL PROTECTED]>
AuthorDate: Sun May 6 14:51:01 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon May 7 12:13:00 2007 -0700

    uml: handle block device hotplug errors
    If a disk fails to open, i.e.  its host file doesn't exist, it won't be
    removable because the hot-unplug code checks the existence of its gendisk.
    This won't exist because it is only allocated for successfully opened disks.
    Thus, a typo on the command line can result in a unusable and unfixable 
    This is fixed by freeing the gendisk if it's there, but not letting that
    affect the removal.
    Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
    Cc: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
 arch/um/drivers/ubd_kern.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 8bd9204..53c36d1 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -788,14 +788,12 @@ static int ubd_id(char **str, int *start_out, int 
 static int ubd_remove(int n, char **error_out)
+       struct gendisk *disk;
        struct ubd *ubd_dev;
        int err = -ENODEV;
-       if(ubd_gendisk[n] == NULL)
-               goto out;
        ubd_dev = &ubd_devs[n];
        if(ubd_dev->file == NULL)
@@ -806,9 +804,12 @@ static int ubd_remove(int n, char **error_out)
        if(ubd_dev->count > 0)
                goto out;
-       del_gendisk(ubd_gendisk[n]);
-       put_disk(ubd_gendisk[n]);
-       ubd_gendisk[n] = NULL;
+       disk = ubd_gendisk[n];
+       ubd_gendisk[n] = NULL;
+       if(disk != NULL){
+               del_gendisk(disk);
+               put_disk(disk);
+       }
        if(fake_gendisk[n] != NULL){
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to