aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.vnet.ibm.com>2009-06-12 04:26:27 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2009-06-12 04:27:31 -0400
commite45efa99b0b0035a2afc192c242e37eec5477497 (patch)
treeb377f49c9af4578b97c1b401d76ab779aec9f15a
parentbcf5cef7db869dd3b0ec55ad99641e66b2f5cf02 (diff)
[S390] cio: fix sanity checks in device_ops.
Some sanity checks in device_ops.c test the output of container_of macros to be !NULL. Test the input parameters instead. Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--drivers/s390/cio/device_ops.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 151754d54745..bf0a24af39a0 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -114,7 +114,7 @@ int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
114 struct subchannel *sch; 114 struct subchannel *sch;
115 int ret; 115 int ret;
116 116
117 if (!cdev) 117 if (!cdev || !cdev->dev.parent)
118 return -ENODEV; 118 return -ENODEV;
119 if (cdev->private->state == DEV_STATE_NOT_OPER) 119 if (cdev->private->state == DEV_STATE_NOT_OPER)
120 return -ENODEV; 120 return -ENODEV;
@@ -122,8 +122,6 @@ int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
122 cdev->private->state != DEV_STATE_W4SENSE) 122 cdev->private->state != DEV_STATE_W4SENSE)
123 return -EINVAL; 123 return -EINVAL;
124 sch = to_subchannel(cdev->dev.parent); 124 sch = to_subchannel(cdev->dev.parent);
125 if (!sch)
126 return -ENODEV;
127 ret = cio_clear(sch); 125 ret = cio_clear(sch);
128 if (ret == 0) 126 if (ret == 0)
129 cdev->private->intparm = intparm; 127 cdev->private->intparm = intparm;
@@ -161,11 +159,9 @@ int ccw_device_start_key(struct ccw_device *cdev, struct ccw1 *cpa,
161 struct subchannel *sch; 159 struct subchannel *sch;
162 int ret; 160 int ret;
163 161
164 if (!cdev) 162 if (!cdev || !cdev->dev.parent)
165 return -ENODEV; 163 return -ENODEV;
166 sch = to_subchannel(cdev->dev.parent); 164 sch = to_subchannel(cdev->dev.parent);
167 if (!sch)
168 return -ENODEV;
169 if (cdev->private->state == DEV_STATE_NOT_OPER) 165 if (cdev->private->state == DEV_STATE_NOT_OPER)
170 return -ENODEV; 166 return -ENODEV;
171 if (cdev->private->state == DEV_STATE_VERIFY || 167 if (cdev->private->state == DEV_STATE_VERIFY ||
@@ -339,7 +335,7 @@ int ccw_device_halt(struct ccw_device *cdev, unsigned long intparm)
339 struct subchannel *sch; 335 struct subchannel *sch;
340 int ret; 336 int ret;
341 337
342 if (!cdev) 338 if (!cdev || !cdev->dev.parent)
343 return -ENODEV; 339 return -ENODEV;
344 if (cdev->private->state == DEV_STATE_NOT_OPER) 340 if (cdev->private->state == DEV_STATE_NOT_OPER)
345 return -ENODEV; 341 return -ENODEV;
@@ -347,8 +343,6 @@ int ccw_device_halt(struct ccw_device *cdev, unsigned long intparm)
347 cdev->private->state != DEV_STATE_W4SENSE) 343 cdev->private->state != DEV_STATE_W4SENSE)
348 return -EINVAL; 344 return -EINVAL;
349 sch = to_subchannel(cdev->dev.parent); 345 sch = to_subchannel(cdev->dev.parent);
350 if (!sch)
351 return -ENODEV;
352 ret = cio_halt(sch); 346 ret = cio_halt(sch);
353 if (ret == 0) 347 if (ret == 0)
354 cdev->private->intparm = intparm; 348 cdev->private->intparm = intparm;
@@ -372,11 +366,9 @@ int ccw_device_resume(struct ccw_device *cdev)
372{ 366{
373 struct subchannel *sch; 367 struct subchannel *sch;
374 368
375 if (!cdev) 369 if (!cdev || !cdev->dev.parent)
376 return -ENODEV; 370 return -ENODEV;
377 sch = to_subchannel(cdev->dev.parent); 371 sch = to_subchannel(cdev->dev.parent);
378 if (!sch)
379 return -ENODEV;
380 if (cdev->private->state == DEV_STATE_NOT_OPER) 372 if (cdev->private->state == DEV_STATE_NOT_OPER)
381 return -ENODEV; 373 return -ENODEV;
382 if (cdev->private->state != DEV_STATE_ONLINE || 374 if (cdev->private->state != DEV_STATE_ONLINE ||
@@ -471,11 +463,11 @@ __u8 ccw_device_get_path_mask(struct ccw_device *cdev)
471{ 463{
472 struct subchannel *sch; 464 struct subchannel *sch;
473 465
474 sch = to_subchannel(cdev->dev.parent); 466 if (!cdev->dev.parent)
475 if (!sch)
476 return 0; 467 return 0;
477 else 468
478 return sch->lpm; 469 sch = to_subchannel(cdev->dev.parent);
470 return sch->lpm;
479} 471}
480 472
481/* 473/*