Commit e45efa99 authored by Sebastian Ott's avatar Sebastian Ott Committed by Martin Schwidefsky

[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: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent bcf5cef7
...@@ -114,7 +114,7 @@ int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm) ...@@ -114,7 +114,7 @@ int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
struct subchannel *sch; struct subchannel *sch;
int ret; int ret;
if (!cdev) if (!cdev || !cdev->dev.parent)
return -ENODEV; return -ENODEV;
if (cdev->private->state == DEV_STATE_NOT_OPER) if (cdev->private->state == DEV_STATE_NOT_OPER)
return -ENODEV; return -ENODEV;
...@@ -122,8 +122,6 @@ int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm) ...@@ -122,8 +122,6 @@ int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
cdev->private->state != DEV_STATE_W4SENSE) cdev->private->state != DEV_STATE_W4SENSE)
return -EINVAL; return -EINVAL;
sch = to_subchannel(cdev->dev.parent); sch = to_subchannel(cdev->dev.parent);
if (!sch)
return -ENODEV;
ret = cio_clear(sch); ret = cio_clear(sch);
if (ret == 0) if (ret == 0)
cdev->private->intparm = intparm; cdev->private->intparm = intparm;
...@@ -161,11 +159,9 @@ int ccw_device_start_key(struct ccw_device *cdev, struct ccw1 *cpa, ...@@ -161,11 +159,9 @@ int ccw_device_start_key(struct ccw_device *cdev, struct ccw1 *cpa,
struct subchannel *sch; struct subchannel *sch;
int ret; int ret;
if (!cdev) if (!cdev || !cdev->dev.parent)
return -ENODEV; return -ENODEV;
sch = to_subchannel(cdev->dev.parent); sch = to_subchannel(cdev->dev.parent);
if (!sch)
return -ENODEV;
if (cdev->private->state == DEV_STATE_NOT_OPER) if (cdev->private->state == DEV_STATE_NOT_OPER)
return -ENODEV; return -ENODEV;
if (cdev->private->state == DEV_STATE_VERIFY || if (cdev->private->state == DEV_STATE_VERIFY ||
...@@ -339,7 +335,7 @@ int ccw_device_halt(struct ccw_device *cdev, unsigned long intparm) ...@@ -339,7 +335,7 @@ int ccw_device_halt(struct ccw_device *cdev, unsigned long intparm)
struct subchannel *sch; struct subchannel *sch;
int ret; int ret;
if (!cdev) if (!cdev || !cdev->dev.parent)
return -ENODEV; return -ENODEV;
if (cdev->private->state == DEV_STATE_NOT_OPER) if (cdev->private->state == DEV_STATE_NOT_OPER)
return -ENODEV; return -ENODEV;
...@@ -347,8 +343,6 @@ int ccw_device_halt(struct ccw_device *cdev, unsigned long intparm) ...@@ -347,8 +343,6 @@ int ccw_device_halt(struct ccw_device *cdev, unsigned long intparm)
cdev->private->state != DEV_STATE_W4SENSE) cdev->private->state != DEV_STATE_W4SENSE)
return -EINVAL; return -EINVAL;
sch = to_subchannel(cdev->dev.parent); sch = to_subchannel(cdev->dev.parent);
if (!sch)
return -ENODEV;
ret = cio_halt(sch); ret = cio_halt(sch);
if (ret == 0) if (ret == 0)
cdev->private->intparm = intparm; cdev->private->intparm = intparm;
...@@ -372,11 +366,9 @@ int ccw_device_resume(struct ccw_device *cdev) ...@@ -372,11 +366,9 @@ int ccw_device_resume(struct ccw_device *cdev)
{ {
struct subchannel *sch; struct subchannel *sch;
if (!cdev) if (!cdev || !cdev->dev.parent)
return -ENODEV; return -ENODEV;
sch = to_subchannel(cdev->dev.parent); sch = to_subchannel(cdev->dev.parent);
if (!sch)
return -ENODEV;
if (cdev->private->state == DEV_STATE_NOT_OPER) if (cdev->private->state == DEV_STATE_NOT_OPER)
return -ENODEV; return -ENODEV;
if (cdev->private->state != DEV_STATE_ONLINE || if (cdev->private->state != DEV_STATE_ONLINE ||
...@@ -471,11 +463,11 @@ __u8 ccw_device_get_path_mask(struct ccw_device *cdev) ...@@ -471,11 +463,11 @@ __u8 ccw_device_get_path_mask(struct ccw_device *cdev)
{ {
struct subchannel *sch; struct subchannel *sch;
sch = to_subchannel(cdev->dev.parent); if (!cdev->dev.parent)
if (!sch)
return 0; return 0;
else
return sch->lpm; sch = to_subchannel(cdev->dev.parent);
return sch->lpm;
} }
/* /*
......
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