Commit 7337194f authored by Cornelia Huck's avatar Cornelia Huck Committed by Heiko Carstens

[S390] dasd: Fix cleanup in dasd_{fba,diag}_check_characteristics().

Signed-off-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
parent 626f3117
...@@ -333,7 +333,8 @@ dasd_diag_check_device(struct dasd_device *device) ...@@ -333,7 +333,8 @@ dasd_diag_check_device(struct dasd_device *device)
if (IS_ERR(block)) { if (IS_ERR(block)) {
DEV_MESSAGE(KERN_WARNING, device, "%s", DEV_MESSAGE(KERN_WARNING, device, "%s",
"could not allocate dasd block structure"); "could not allocate dasd block structure");
kfree(device->private); device->private = NULL;
kfree(private);
return PTR_ERR(block); return PTR_ERR(block);
} }
device->block = block; device->block = block;
...@@ -348,7 +349,8 @@ dasd_diag_check_device(struct dasd_device *device) ...@@ -348,7 +349,8 @@ dasd_diag_check_device(struct dasd_device *device)
if (rc) { if (rc) {
DEV_MESSAGE(KERN_WARNING, device, "failed to retrieve device " DEV_MESSAGE(KERN_WARNING, device, "failed to retrieve device "
"information (rc=%d)", rc); "information (rc=%d)", rc);
return -ENOTSUPP; rc = -ENOTSUPP;
goto out;
} }
/* Figure out position of label block */ /* Figure out position of label block */
...@@ -362,7 +364,8 @@ dasd_diag_check_device(struct dasd_device *device) ...@@ -362,7 +364,8 @@ dasd_diag_check_device(struct dasd_device *device)
default: default:
DEV_MESSAGE(KERN_WARNING, device, "unsupported device class " DEV_MESSAGE(KERN_WARNING, device, "unsupported device class "
"(class=%d)", private->rdc_data.vdev_class); "(class=%d)", private->rdc_data.vdev_class);
return -ENOTSUPP; rc = -ENOTSUPP;
goto out;
} }
DBF_DEV_EVENT(DBF_INFO, device, DBF_DEV_EVENT(DBF_INFO, device,
...@@ -379,7 +382,8 @@ dasd_diag_check_device(struct dasd_device *device) ...@@ -379,7 +382,8 @@ dasd_diag_check_device(struct dasd_device *device)
if (label == NULL) { if (label == NULL) {
DEV_MESSAGE(KERN_WARNING, device, "%s", DEV_MESSAGE(KERN_WARNING, device, "%s",
"No memory to allocate initialization request"); "No memory to allocate initialization request");
return -ENOMEM; rc = -ENOMEM;
goto out;
} }
rc = 0; rc = 0;
end_block = 0; end_block = 0;
...@@ -403,7 +407,7 @@ dasd_diag_check_device(struct dasd_device *device) ...@@ -403,7 +407,7 @@ dasd_diag_check_device(struct dasd_device *device)
DEV_MESSAGE(KERN_WARNING, device, "%s", DEV_MESSAGE(KERN_WARNING, device, "%s",
"DIAG call failed"); "DIAG call failed");
rc = -EOPNOTSUPP; rc = -EOPNOTSUPP;
goto out; goto out_label;
} }
mdsk_term_io(device); mdsk_term_io(device);
if (rc == 0) if (rc == 0)
...@@ -413,7 +417,7 @@ dasd_diag_check_device(struct dasd_device *device) ...@@ -413,7 +417,7 @@ dasd_diag_check_device(struct dasd_device *device)
DEV_MESSAGE(KERN_WARNING, device, "device access failed " DEV_MESSAGE(KERN_WARNING, device, "device access failed "
"(rc=%d)", rc); "(rc=%d)", rc);
rc = -EIO; rc = -EIO;
goto out; goto out_label;
} }
/* check for label block */ /* check for label block */
if (memcmp(label->label_id, DASD_DIAG_CMS1, if (memcmp(label->label_id, DASD_DIAG_CMS1,
...@@ -439,8 +443,15 @@ dasd_diag_check_device(struct dasd_device *device) ...@@ -439,8 +443,15 @@ dasd_diag_check_device(struct dasd_device *device)
(unsigned long) (block->blocks << (unsigned long) (block->blocks <<
block->s2b_shift) >> 1); block->s2b_shift) >> 1);
} }
out: out_label:
free_page((long) label); free_page((long) label);
out:
if (rc) {
device->block = NULL;
dasd_free_block(block);
device->private = NULL;
kfree(private);
}
return rc; return rc;
} }
......
...@@ -139,7 +139,8 @@ dasd_fba_check_characteristics(struct dasd_device *device) ...@@ -139,7 +139,8 @@ dasd_fba_check_characteristics(struct dasd_device *device)
if (IS_ERR(block)) { if (IS_ERR(block)) {
DEV_MESSAGE(KERN_WARNING, device, "%s", DEV_MESSAGE(KERN_WARNING, device, "%s",
"could not allocate dasd block structure"); "could not allocate dasd block structure");
kfree(device->private); device->private = NULL;
kfree(private);
return PTR_ERR(block); return PTR_ERR(block);
} }
device->block = block; device->block = block;
...@@ -152,6 +153,10 @@ dasd_fba_check_characteristics(struct dasd_device *device) ...@@ -152,6 +153,10 @@ dasd_fba_check_characteristics(struct dasd_device *device)
DEV_MESSAGE(KERN_WARNING, device, DEV_MESSAGE(KERN_WARNING, device,
"Read device characteristics returned error %d", "Read device characteristics returned error %d",
rc); rc);
device->block = NULL;
dasd_free_block(block);
device->private = NULL;
kfree(private);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment