if (IS_ERR(block)) {
DEV_MESSAGE(KERN_WARNING, device, "%s",
"could not allocate dasd block structure");
- kfree(device->private);
+ device->private = NULL;
+ kfree(private);
return PTR_ERR(block);
}
device->block = block;
if (rc) {
DEV_MESSAGE(KERN_WARNING, device, "failed to retrieve device "
"information (rc=%d)", rc);
- return -ENOTSUPP;
+ rc = -ENOTSUPP;
+ goto out;
}
/* Figure out position of label block */
default:
DEV_MESSAGE(KERN_WARNING, device, "unsupported device class "
"(class=%d)", private->rdc_data.vdev_class);
- return -ENOTSUPP;
+ rc = -ENOTSUPP;
+ goto out;
}
DBF_DEV_EVENT(DBF_INFO, device,
if (label == NULL) {
DEV_MESSAGE(KERN_WARNING, device, "%s",
"No memory to allocate initialization request");
- return -ENOMEM;
+ rc = -ENOMEM;
+ goto out;
}
rc = 0;
end_block = 0;
DEV_MESSAGE(KERN_WARNING, device, "%s",
"DIAG call failed");
rc = -EOPNOTSUPP;
- goto out;
+ goto out_label;
}
mdsk_term_io(device);
if (rc == 0)
DEV_MESSAGE(KERN_WARNING, device, "device access failed "
"(rc=%d)", rc);
rc = -EIO;
- goto out;
+ goto out_label;
}
/* check for label block */
if (memcmp(label->label_id, DASD_DIAG_CMS1,
(unsigned long) (block->blocks <<
block->s2b_shift) >> 1);
}
-out:
+out_label:
free_page((long) label);
+out:
+ if (rc) {
+ device->block = NULL;
+ dasd_free_block(block);
+ device->private = NULL;
+ kfree(private);
+ }
return rc;
}
if (IS_ERR(block)) {
DEV_MESSAGE(KERN_WARNING, device, "%s",
"could not allocate dasd block structure");
- kfree(device->private);
+ device->private = NULL;
+ kfree(private);
return PTR_ERR(block);
}
device->block = block;
DEV_MESSAGE(KERN_WARNING, device,
"Read device characteristics returned error %d",
rc);
+ device->block = NULL;
+ dasd_free_block(block);
+ device->private = NULL;
+ kfree(private);
return rc;
}