summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/fs/zfs/zvol.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/usr/src/uts/common/fs/zfs/zvol.c b/usr/src/uts/common/fs/zfs/zvol.c
index 1335207aa6..caf80e640e 100644
--- a/usr/src/uts/common/fs/zfs/zvol.c
+++ b/usr/src/uts/common/fs/zfs/zvol.c
@@ -903,10 +903,18 @@ zvol_minphys(struct buf *bp)
int
zvol_read(dev_t dev, uio_t *uio, cred_t *cr)
{
- zvol_state_t *zv = ddi_get_soft_state(zvol_state, getminor(dev));
+ minor_t minor = getminor(dev);
+ zvol_state_t *zv;
rl_t *rl;
int error = 0;
+ if (minor == 0) /* This is the control device */
+ return (ENXIO);
+
+ zv = ddi_get_soft_state(zvol_state, minor);
+ if (zv == NULL)
+ return (ENXIO);
+
rl = zfs_range_lock(&zv->zv_znode, uio->uio_loffset, uio->uio_resid,
RL_READER);
while (uio->uio_resid > 0) {
@@ -924,10 +932,18 @@ zvol_read(dev_t dev, uio_t *uio, cred_t *cr)
int
zvol_write(dev_t dev, uio_t *uio, cred_t *cr)
{
- zvol_state_t *zv = ddi_get_soft_state(zvol_state, getminor(dev));
+ minor_t minor = getminor(dev);
+ zvol_state_t *zv;
rl_t *rl;
int error = 0;
+ if (minor == 0) /* This is the control device */
+ return (ENXIO);
+
+ zv = ddi_get_soft_state(zvol_state, minor);
+ if (zv == NULL)
+ return (ENXIO);
+
rl = zfs_range_lock(&zv->zv_znode, uio->uio_loffset, uio->uio_resid,
RL_WRITER);
while (uio->uio_resid > 0) {