summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/diskmap.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/dev/diskmap.c b/sys/dev/diskmap.c
index e035ee36466..d7293e2b115 100644
--- a/sys/dev/diskmap.c
+++ b/sys/dev/diskmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diskmap.c,v 1.25 2019/08/05 08:46:46 anton Exp $ */
+/* $OpenBSD: diskmap.c,v 1.26 2019/08/06 07:16:48 anton Exp $ */
/*
* Copyright (c) 2009, 2010 Joel Sing <jsing@openbsd.org>
@@ -60,10 +60,10 @@ diskmapioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
struct file *fp0 = NULL, *fp = NULL;
struct vnode *vp = NULL;
char *devname, flags;
- int fd, error = EINVAL;
+ int error, fd;
if (cmd != DIOCMAP)
- return EINVAL;
+ return ENOTTY;
/*
* Map a request for a disk to the correct device. We should be
@@ -73,11 +73,13 @@ diskmapioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
dm = (struct dk_diskmap *)addr;
fd = dm->fd;
devname = malloc(PATH_MAX, M_DEVBUF, M_WAITOK);
- if (copyinstr(dm->device, devname, PATH_MAX, NULL))
+ if ((error = copyinstr(dm->device, devname, PATH_MAX, NULL)) != 0)
goto invalid;
- if (disk_map(devname, devname, PATH_MAX, dm->flags) == 0)
- if (copyoutstr(devname, dm->device, PATH_MAX, NULL))
+ if (disk_map(devname, devname, PATH_MAX, dm->flags) == 0) {
+ error = copyoutstr(devname, dm->device, PATH_MAX, NULL);
+ if (error != 0)
goto invalid;
+ }
/* Attempt to open actual device. */
if ((error = getvnode(p, fd, &fp0)) != 0)
@@ -142,7 +144,7 @@ invalid:
free(devname, M_DEVBUF, PATH_MAX);
- return (error);
+ return error;
}
int