Commit 294001a8 authored by Stefan Haberland's avatar Stefan Haberland Committed by Martin Schwidefsky

[S390] dasd: fix possible NULL pointer errors

Fix possible NULL pointer in DASD messages and correct discipline
checking.
Signed-off-by: default avatarStefan Haberland <stefan.haberland@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent b04da8bf
...@@ -1004,8 +1004,8 @@ static void dasd_handle_killed_request(struct ccw_device *cdev, ...@@ -1004,8 +1004,8 @@ static void dasd_handle_killed_request(struct ccw_device *cdev,
if (device == NULL || if (device == NULL ||
device != dasd_device_from_cdev_locked(cdev) || device != dasd_device_from_cdev_locked(cdev) ||
strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
DBF_DEV_EVENT(DBF_DEBUG, device, "invalid device in request: " DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s",
"bus_id %s", dev_name(&cdev->dev)); "invalid device in request");
return; return;
} }
...@@ -1078,8 +1078,8 @@ void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm, ...@@ -1078,8 +1078,8 @@ void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
device = (struct dasd_device *) cqr->startdev; device = (struct dasd_device *) cqr->startdev;
if (!device || if (!device ||
strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
DBF_DEV_EVENT(DBF_DEBUG, device, "invalid device in request: " DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s",
"bus_id %s", dev_name(&cdev->dev)); "invalid device in request");
return; return;
} }
......
...@@ -3033,7 +3033,7 @@ static void dasd_eckd_dump_sense_ccw(struct dasd_device *device, ...@@ -3033,7 +3033,7 @@ static void dasd_eckd_dump_sense_ccw(struct dasd_device *device,
len += sprintf(page + len, KERN_ERR PRINTK_HEADER len += sprintf(page + len, KERN_ERR PRINTK_HEADER
" in req: %p CS: 0x%02X DS: 0x%02X CC: 0x%02X RC: %d\n", " in req: %p CS: 0x%02X DS: 0x%02X CC: 0x%02X RC: %d\n",
req, scsw_cstat(&irb->scsw), scsw_dstat(&irb->scsw), req, scsw_cstat(&irb->scsw), scsw_dstat(&irb->scsw),
scsw_cc(&irb->scsw), req->intrc); scsw_cc(&irb->scsw), req ? req->intrc : 0);
len += sprintf(page + len, KERN_ERR PRINTK_HEADER len += sprintf(page + len, KERN_ERR PRINTK_HEADER
" device %s: Failing CCW: %p\n", " device %s: Failing CCW: %p\n",
dev_name(&device->cdev->dev), dev_name(&device->cdev->dev),
......
...@@ -260,7 +260,7 @@ static int dasd_ioctl_information(struct dasd_block *block, ...@@ -260,7 +260,7 @@ static int dasd_ioctl_information(struct dasd_block *block,
struct ccw_dev_id dev_id; struct ccw_dev_id dev_id;
base = block->base; base = block->base;
if (!base->discipline->fill_info) if (!base->discipline || !base->discipline->fill_info)
return -EINVAL; return -EINVAL;
dasd_info = kzalloc(sizeof(struct dasd_information2_t), GFP_KERNEL); dasd_info = kzalloc(sizeof(struct dasd_information2_t), GFP_KERNEL);
...@@ -303,10 +303,7 @@ static int dasd_ioctl_information(struct dasd_block *block, ...@@ -303,10 +303,7 @@ static int dasd_ioctl_information(struct dasd_block *block,
dasd_info->features |= dasd_info->features |=
((base->features & DASD_FEATURE_READONLY) != 0); ((base->features & DASD_FEATURE_READONLY) != 0);
if (base->discipline) memcpy(dasd_info->type, base->discipline->name, 4);
memcpy(dasd_info->type, base->discipline->name, 4);
else
memcpy(dasd_info->type, "none", 4);
if (block->request_queue->request_fn) { if (block->request_queue->request_fn) {
struct list_head *l; struct list_head *l;
......
...@@ -72,7 +72,7 @@ dasd_devices_show(struct seq_file *m, void *v) ...@@ -72,7 +72,7 @@ dasd_devices_show(struct seq_file *m, void *v)
/* Print device number. */ /* Print device number. */
seq_printf(m, "%s", dev_name(&device->cdev->dev)); seq_printf(m, "%s", dev_name(&device->cdev->dev));
/* Print discipline string. */ /* Print discipline string. */
if (device != NULL && device->discipline != NULL) if (device->discipline != NULL)
seq_printf(m, "(%s)", device->discipline->name); seq_printf(m, "(%s)", device->discipline->name);
else else
seq_printf(m, "(none)"); seq_printf(m, "(none)");
...@@ -92,10 +92,7 @@ dasd_devices_show(struct seq_file *m, void *v) ...@@ -92,10 +92,7 @@ dasd_devices_show(struct seq_file *m, void *v)
substr = (device->features & DASD_FEATURE_READONLY) ? "(ro)" : " "; substr = (device->features & DASD_FEATURE_READONLY) ? "(ro)" : " ";
seq_printf(m, "%4s: ", substr); seq_printf(m, "%4s: ", substr);
/* Print device status information. */ /* Print device status information. */
switch ((device != NULL) ? device->state : -1) { switch (device->state) {
case -1:
seq_printf(m, "unknown");
break;
case DASD_STATE_NEW: case DASD_STATE_NEW:
seq_printf(m, "new"); seq_printf(m, "new");
break; break;
......
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