[S390] dasd: fix possible NULL pointer errors

Fix possible NULL pointer in DASD messages and correct discipline
checking.

Signed-off-by: Stefan Haberland <stefan.haberland@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Stefan Haberland and committed by
Martin Schwidefsky
294001a8 b04da8bf

+9 -15
+4 -4
drivers/s390/block/dasd.c
··· 1004 1004 if (device == NULL || 1005 1005 device != dasd_device_from_cdev_locked(cdev) || 1006 1006 strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { 1007 - DBF_DEV_EVENT(DBF_DEBUG, device, "invalid device in request: " 1008 - "bus_id %s", dev_name(&cdev->dev)); 1007 + DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s", 1008 + "invalid device in request"); 1009 1009 return; 1010 1010 } 1011 1011 ··· 1078 1078 device = (struct dasd_device *) cqr->startdev; 1079 1079 if (!device || 1080 1080 strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { 1081 - DBF_DEV_EVENT(DBF_DEBUG, device, "invalid device in request: " 1082 - "bus_id %s", dev_name(&cdev->dev)); 1081 + DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s", 1082 + "invalid device in request"); 1083 1083 return; 1084 1084 } 1085 1085
+1 -1
drivers/s390/block/dasd_eckd.c
··· 3033 3033 len += sprintf(page + len, KERN_ERR PRINTK_HEADER 3034 3034 " in req: %p CS: 0x%02X DS: 0x%02X CC: 0x%02X RC: %d\n", 3035 3035 req, scsw_cstat(&irb->scsw), scsw_dstat(&irb->scsw), 3036 - scsw_cc(&irb->scsw), req->intrc); 3036 + scsw_cc(&irb->scsw), req ? req->intrc : 0); 3037 3037 len += sprintf(page + len, KERN_ERR PRINTK_HEADER 3038 3038 " device %s: Failing CCW: %p\n", 3039 3039 dev_name(&device->cdev->dev),
+2 -5
drivers/s390/block/dasd_ioctl.c
··· 260 260 struct ccw_dev_id dev_id; 261 261 262 262 base = block->base; 263 - if (!base->discipline->fill_info) 263 + if (!base->discipline || !base->discipline->fill_info) 264 264 return -EINVAL; 265 265 266 266 dasd_info = kzalloc(sizeof(struct dasd_information2_t), GFP_KERNEL); ··· 303 303 dasd_info->features |= 304 304 ((base->features & DASD_FEATURE_READONLY) != 0); 305 305 306 - if (base->discipline) 307 - memcpy(dasd_info->type, base->discipline->name, 4); 308 - else 309 - memcpy(dasd_info->type, "none", 4); 306 + memcpy(dasd_info->type, base->discipline->name, 4); 310 307 311 308 if (block->request_queue->request_fn) { 312 309 struct list_head *l;
+2 -5
drivers/s390/block/dasd_proc.c
··· 72 72 /* Print device number. */ 73 73 seq_printf(m, "%s", dev_name(&device->cdev->dev)); 74 74 /* Print discipline string. */ 75 - if (device != NULL && device->discipline != NULL) 75 + if (device->discipline != NULL) 76 76 seq_printf(m, "(%s)", device->discipline->name); 77 77 else 78 78 seq_printf(m, "(none)"); ··· 92 92 substr = (device->features & DASD_FEATURE_READONLY) ? "(ro)" : " "; 93 93 seq_printf(m, "%4s: ", substr); 94 94 /* Print device status information. */ 95 - switch ((device != NULL) ? device->state : -1) { 96 - case -1: 97 - seq_printf(m, "unknown"); 98 - break; 95 + switch (device->state) { 99 96 case DASD_STATE_NEW: 100 97 seq_printf(m, "new"); 101 98 break;