summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Valchev <pvalchev@cvs.openbsd.org>2002-02-14 22:57:19 +0000
committerPeter Valchev <pvalchev@cvs.openbsd.org>2002-02-14 22:57:19 +0000
commitf2dcd99cca731fe6ef0a61ca6a9d64872439febf (patch)
tree7a11f5c653196e126ec053086c3f0cf0cd39123c
parent0e740613f2fbdd26969bca268c0429b96c37ebb8 (diff)
More FREF/FRELE fixes
-rw-r--r--sys/compat/hpux/hpux_file.c54
-rw-r--r--sys/compat/ibcs2/ibcs2_ioctl.c94
-rw-r--r--sys/compat/ossaudio/ossaudio.c195
-rw-r--r--sys/compat/sunos/sunos_ioctl.c142
-rw-r--r--sys/compat/svr4/svr4_stream.c93
-rw-r--r--sys/compat/ultrix/ultrix_ioctl.c128
6 files changed, 433 insertions, 273 deletions
diff --git a/sys/compat/hpux/hpux_file.c b/sys/compat/hpux/hpux_file.c
index 1e49b348d10..aa544da76fd 100644
--- a/sys/compat/hpux/hpux_file.c
+++ b/sys/compat/hpux/hpux_file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hpux_file.c,v 1.9 2001/11/05 19:48:22 art Exp $ */
+/* $OpenBSD: hpux_file.c,v 1.10 2002/02/14 22:57:18 pvalchev Exp $ */
/* $NetBSD: hpux_file.c,v 1.5 1997/04/27 21:40:48 thorpej Exp $ */
/*
@@ -222,6 +222,7 @@ hpux_sys_fcntl(p, v, retval)
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
return (EBADF);
+ FREF(fp);
pop = &p->p_fd->fd_ofileflags[SCARG(uap, fd)];
arg = SCARG(uap, arg);
@@ -257,8 +258,10 @@ hpux_sys_fcntl(p, v, retval)
/* Fall into F_SETLK */
case HPUXF_SETLK:
- if (fp->f_type != DTYPE_VNODE)
- return (EBADF);
+ if (fp->f_type != DTYPE_VNODE) {
+ error = EBADF;
+ goto aout;
+ }
vp = (struct vnode *)fp->f_data;
@@ -266,7 +269,7 @@ hpux_sys_fcntl(p, v, retval)
error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&hfl,
sizeof (hfl));
if (error)
- return (error);
+ goto bad;
fl.l_start = hfl.hl_start;
fl.l_len = hfl.hl_len;
@@ -278,30 +281,39 @@ hpux_sys_fcntl(p, v, retval)
switch (fl.l_type) {
case F_RDLCK:
- if ((fp->f_flag & FREAD) == 0)
- return (EBADF);
+ if ((fp->f_flag & FREAD) == 0) {
+ error = EBADF;
+ goto out;
+ }
p->p_flag |= P_ADVLOCK;
- return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
+ error = VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg);
+ goto out;
case F_WRLCK:
- if ((fp->f_flag & FWRITE) == 0)
- return (EBADF);
+ if ((fp->f_flag & FWRITE) == 0) {
+ error = EBADF;
+ goto out;
+ }
p->p_flag |= P_ADVLOCK;
- return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
+ error = VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg);
+ goto out;
case F_UNLCK:
- return (VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &fl,
- F_POSIX));
+ error = VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &fl,
+ F_POSIX);
+ goto out;
default:
- return (EINVAL);
+ error = EINVAL;
+ goto out;
}
/* NOTREACHED */
case F_GETLK:
if (fp->f_type != DTYPE_VNODE)
- return (EBADF);
+ error = EBADF;
+ goto out;
vp = (struct vnode *)fp->f_data;
@@ -309,7 +321,7 @@ hpux_sys_fcntl(p, v, retval)
error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&hfl,
sizeof (hfl));
if (error)
- return (error);
+ goto bad;
fl.l_start = hfl.hl_start;
fl.l_len = hfl.hl_len;
@@ -321,18 +333,20 @@ hpux_sys_fcntl(p, v, retval)
if ((error =
VOP_ADVLOCK(vp, (caddr_t)p, F_GETLK, &fl, F_POSIX)))
- return (error);
+ goto bad;
hfl.hl_start = fl.l_start;
hfl.hl_len = fl.l_len;
hfl.hl_pid = fl.l_pid;
hfl.hl_type = fl.l_type;
hfl.hl_whence = fl.l_whence;
- return (copyout((caddr_t)&hfl, (caddr_t)SCARG(uap, arg),
- sizeof (hfl)));
+ error = copyout((caddr_t)&hfl, (caddr_t)SCARG(uap, arg),
+ sizeof (hfl));
+ goto out;
default:
- return (EINVAL);
+ error = EINVAL;
+ goto out;
}
/*
@@ -363,6 +377,8 @@ hpux_sys_fcntl(p, v, retval)
if (mode & O_EXCL)
*retval |= HPUXFEXCL;
}
+bad:
+ FRELE(fp);
return (error);
}
diff --git a/sys/compat/ibcs2/ibcs2_ioctl.c b/sys/compat/ibcs2/ibcs2_ioctl.c
index f4c7291e1be..a40ee811975 100644
--- a/sys/compat/ibcs2/ibcs2_ioctl.c
+++ b/sys/compat/ibcs2/ibcs2_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ibcs2_ioctl.c,v 1.9 2001/10/26 12:03:27 art Exp $ */
+/* $OpenBSD: ibcs2_ioctl.c,v 1.10 2002/02/14 22:57:18 pvalchev Exp $ */
/* $NetBSD: ibcs2_ioctl.c,v 1.12 1996/08/10 09:08:26 mycroft Exp $ */
/*
@@ -347,10 +347,12 @@ ibcs2_sys_ioctl(p, v, retval)
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
return (EBADF);
+ FREF(fp);
if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
DPRINTF(("ibcs2_ioctl(%d): bad fp flag ", p->p_pid));
- return EBADF;
+ error = EBADF;
+ goto out;
}
ctl = fp->f_ops->fo_ioctl;
@@ -365,7 +367,7 @@ ibcs2_sys_ioctl(p, v, retval)
struct ibcs2_termio st;
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0)
- return error;
+ goto out;
btios2stios (&bts, &sts);
if (SCARG(uap, cmd) == IBCS2_TCGETA) {
@@ -375,10 +377,12 @@ ibcs2_sys_ioctl(p, v, retval)
if (error)
DPRINTF(("ibcs2_ioctl(%d): copyout failed ",
p->p_pid));
- return error;
- } else
- return copyout((caddr_t)&sts, SCARG(uap, data),
+ goto out;
+ } else {
+ error = copyout((caddr_t)&sts, SCARG(uap, data),
sizeof (sts));
+ goto out;
+ }
/*NOTREACHED*/
}
@@ -394,14 +398,14 @@ ibcs2_sys_ioctl(p, v, retval)
sizeof(st))) != 0) {
DPRINTF(("ibcs2_ioctl(%d): TCSET copyin failed ",
p->p_pid));
- return error;
+ goto out;
}
/* get full BSD termios so we don't lose information */
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0) {
DPRINTF(("ibcs2_ioctl(%d): TCSET ctl failed fd %d ",
p->p_pid, SCARG(uap, fd)));
- return error;
+ goto out;
}
/*
@@ -412,8 +416,9 @@ ibcs2_sys_ioctl(p, v, retval)
stio2stios(&st, &sts);
stios2btios(&sts, &bts);
- return (*ctl)(fp, SCARG(uap, cmd) - IBCS2_TCSETA + TIOCSETA,
+ error = (*ctl)(fp, SCARG(uap, cmd) - IBCS2_TCSETA + TIOCSETA,
(caddr_t)&bts, p);
+ goto out;
}
case IBCS2_XCSETA:
@@ -425,11 +430,12 @@ ibcs2_sys_ioctl(p, v, retval)
if ((error = copyin(SCARG(uap, data), (caddr_t)&sts,
sizeof (sts))) != 0) {
- return error;
+ goto out;
}
stios2btios (&sts, &bts);
- return (*ctl)(fp, SCARG(uap, cmd) - IBCS2_XCSETA + TIOCSETA,
+ error = (*ctl)(fp, SCARG(uap, cmd) - IBCS2_XCSETA + TIOCSETA,
(caddr_t)&bts, p);
+ goto out;
}
case IBCS2_OXCSETA:
@@ -441,16 +447,18 @@ ibcs2_sys_ioctl(p, v, retval)
if ((error = copyin(SCARG(uap, data), (caddr_t)&sts,
sizeof (sts))) != 0) {
- return error;
+ goto out;
}
stios2btios (&sts, &bts);
- return (*ctl)(fp, SCARG(uap, cmd) - IBCS2_OXCSETA + TIOCSETA,
+ error = (*ctl)(fp, SCARG(uap, cmd) - IBCS2_OXCSETA + TIOCSETA,
(caddr_t)&bts, p);
+ goto out;
}
case IBCS2_TCSBRK:
DPRINTF(("ibcs2_ioctl(%d): TCSBRK ", p->p_pid));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
case IBCS2_TCXONC:
{
@@ -458,13 +466,17 @@ ibcs2_sys_ioctl(p, v, retval)
case 0:
case 1:
DPRINTF(("ibcs2_ioctl(%d): TCXONC ", p->p_pid));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
case 2:
- return (*ctl)(fp, TIOCSTOP, (caddr_t)0, p);
+ error = (*ctl)(fp, TIOCSTOP, (caddr_t)0, p);
+ goto out;
case 3:
- return (*ctl)(fp, TIOCSTART, (caddr_t)1, p);
+ error = (*ctl)(fp, TIOCSTART, (caddr_t)1, p);
+ goto out;
default:
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
}
@@ -483,22 +495,27 @@ ibcs2_sys_ioctl(p, v, retval)
arg = FREAD | FWRITE;
break;
default:
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
- return (*ctl)(fp, TIOCFLUSH, (caddr_t)&arg, p);
+ error = (*ctl)(fp, TIOCFLUSH, (caddr_t)&arg, p);
+ goto out;
}
case IBCS2_TIOCGWINSZ:
SCARG(uap, cmd) = TIOCGWINSZ;
- return sys_ioctl(p, uap, retval);
+ error = sys_ioctl(p, uap, retval);
+ goto out;
case IBCS2_TIOCSWINSZ:
SCARG(uap, cmd) = TIOCSWINSZ;
- return sys_ioctl(p, uap, retval);
+ error = sys_ioctl(p, uap, retval);
+ goto out;
case IBCS2_TIOCGPGRP:
- return copyout((caddr_t)&p->p_pgrp->pg_id, SCARG(uap, data),
+ error = copyout((caddr_t)&p->p_pgrp->pg_id, SCARG(uap, data),
sizeof(p->p_pgrp->pg_id));
+ goto out;
case IBCS2_TIOCSPGRP: /* XXX - is uap->data a pointer to pgid? */
{
@@ -507,18 +524,22 @@ ibcs2_sys_ioctl(p, v, retval)
SCARG(&sa, pid) = 0;
SCARG(&sa, pgid) = (int)SCARG(uap, data);
if ((error = sys_setpgid(p, &sa, retval)) != 0)
- return error;
- return 0;
+ goto out;
+ error = 0;
+ goto out;
}
case IBCS2_TCGETSC: /* SCO console - get scancode flags */
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
case IBCS2_TCSETSC: /* SCO console - set scancode flags */
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
case IBCS2_SIOCSOCKSYS:
- return ibcs2_socksys(p, uap, retval);
+ error = ibcs2_socksys(p, uap, retval);
+ goto out;
case IBCS2_FIONBIO:
{
@@ -526,20 +547,27 @@ ibcs2_sys_ioctl(p, v, retval)
if ((error = copyin(SCARG(uap, data), &arg,
sizeof(arg))) != 0)
- return error;
+ goto out;
- return (*ctl)(fp, FIONBIO, (caddr_t)&arg, p);
+ error = (*ctl)(fp, FIONBIO, (caddr_t)&arg, p);
+ goto out;
}
case IBCS2_FIONREAD:
case IBCS2_I_NREAD: /* STREAMS */
SCARG(uap, cmd) = FIONREAD;
- return sys_ioctl(p, uap, retval);
+ error = sys_ioctl(p, uap, retval);
+ goto out;
default:
DPRINTF(("ibcs2_ioctl(%d): unknown cmd 0x%lx ",
p->p_pid, SCARG(uap, cmd)));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
- return ENOSYS;
+ error = ENOSYS;
+
+out:
+ FRELE(fp);
+ return (error);
}
diff --git a/sys/compat/ossaudio/ossaudio.c b/sys/compat/ossaudio/ossaudio.c
index 8795d62e039..71370993a55 100644
--- a/sys/compat/ossaudio/ossaudio.c
+++ b/sys/compat/ossaudio/ossaudio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ossaudio.c,v 1.6 2001/10/26 12:03:27 art Exp $ */
+/* $OpenBSD: ossaudio.c,v 1.7 2002/02/14 22:57:18 pvalchev Exp $ */
/* $NetBSD: ossaudio.c,v 1.23 1997/10/19 07:41:52 augustss Exp $ */
/*
@@ -90,9 +90,12 @@ oss_ioctl_audio(p, uap, retval)
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
return (EBADF);
+ FREF(fp);
- if ((fp->f_flag & (FREAD | FWRITE)) == 0)
- return (EBADF);
+ if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
+ error = EBADF;
+ goto out;
+ }
ioctlf = fp->f_ops->fo_ioctl;
@@ -104,67 +107,67 @@ oss_ioctl_audio(p, uap, retval)
case OSS_SNDCTL_DSP_RESET:
error = ioctlf(fp, AUDIO_FLUSH, (caddr_t)0, p);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_SYNC:
case OSS_SNDCTL_DSP_POST:
error = ioctlf(fp, AUDIO_DRAIN, (caddr_t)0, p);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_SPEED:
AUDIO_INITINFO(&tmpinfo);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
- return error;
+ goto out;
tmpinfo.play.sample_rate =
tmpinfo.record.sample_rate = idat;
error = ioctlf(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
DPRINTF(("oss_sys_ioctl: SNDCTL_DSP_SPEED %d = %d\n",
idat, error));
if (error)
- return error;
+ goto out;
/* fall into ... */
case OSS_SOUND_PCM_READ_RATE:
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
- return error;
+ goto out;
idat = tmpinfo.play.sample_rate;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_STEREO:
AUDIO_INITINFO(&tmpinfo);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
- return error;
+ goto out;
tmpinfo.play.channels =
tmpinfo.record.channels = idat ? 2 : 1;
(void) ioctlf(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
- return error;
+ goto out;
idat = tmpinfo.play.channels - 1;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_GETBLKSIZE:
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
- return error;
+ goto out;
setblocksize(fp, &tmpinfo, p);
idat = tmpinfo.blocksize;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_SETFMT:
AUDIO_INITINFO(&tmpinfo);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
- return error;
+ goto out;
switch (idat) {
case OSS_AFMT_MU_LAW:
tmpinfo.play.precision =
@@ -215,14 +218,15 @@ oss_ioctl_audio(p, uap, retval)
tmpinfo.record.encoding = AUDIO_ENCODING_ULINEAR_BE;
break;
default:
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
(void) ioctlf(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
/* fall into ... */
case OSS_SOUND_PCM_READ_BITS:
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
- return error;
+ goto out;
switch (tmpinfo.play.encoding) {
case AUDIO_ENCODING_ULAW:
idat = OSS_AFMT_MU_LAW;
@@ -260,13 +264,13 @@ oss_ioctl_audio(p, uap, retval)
}
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_CHANNELS:
AUDIO_INITINFO(&tmpinfo);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
- return error;
+ goto out;
tmpinfo.play.channels =
tmpinfo.record.channels = idat;
(void) ioctlf(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
@@ -274,23 +278,24 @@ oss_ioctl_audio(p, uap, retval)
case OSS_SOUND_PCM_READ_CHANNELS:
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
- return error;
+ goto out;
idat = tmpinfo.play.channels;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
case OSS_SOUND_PCM_WRITE_FILTER:
case OSS_SOUND_PCM_READ_FILTER:
- return EINVAL; /* XXX unimplemented */
+ error = EINVAL; /* XXX unimplemented */
+ goto out;
case OSS_SNDCTL_DSP_SUBDIVIDE:
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
- return error;
+ goto out;
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
setblocksize(fp, &tmpinfo, p);
if (error)
- return error;
+ goto out;
if (idat == 0)
idat = tmpinfo.play.buffer_size / tmpinfo.blocksize;
idat = (tmpinfo.play.buffer_size / idat) & -4;
@@ -298,19 +303,21 @@ oss_ioctl_audio(p, uap, retval)
tmpinfo.blocksize = idat;
error = ioctlf(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
if (error)
- return error;
+ goto out;
idat = tmpinfo.play.buffer_size / tmpinfo.blocksize;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_SETFRAGMENT:
AUDIO_INITINFO(&tmpinfo);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
- return error;
- if ((idat & 0xffff) < 4 || (idat & 0xffff) > 17)
- return EINVAL;
+ goto out;
+ if ((idat & 0xffff) < 4 || (idat & 0xffff) > 17) {
+ error = EINVAL;
+ goto out;
+ }
tmpinfo.blocksize = 1 << (idat & 0xffff);
tmpinfo.hiwat = (idat >> 16) & 0x7fff;
DPRINTF(("oss_audio: SETFRAGMENT blksize=%d, hiwat=%d\n",
@@ -320,14 +327,14 @@ oss_ioctl_audio(p, uap, retval)
(void) ioctlf(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
- return error;
+ goto out;
u = tmpinfo.blocksize;
for(idat = 0; u > 1; idat++, u >>= 1)
;
idat |= (tmpinfo.hiwat & 0x7fff) << 16;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_GETFMTS:
for(idat = 0, tmpenc.index = 0;
@@ -382,12 +389,12 @@ oss_ioctl_audio(p, uap, retval)
DPRINTF(("oss_sys_ioctl: SNDCTL_DSP_GETFMTS = %x\n", idat));
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_GETOSPACE:
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
- return error;
+ goto out;
setblocksize(fp, &tmpinfo, p);
bufinfo.fragsize = tmpinfo.blocksize;
bufinfo.fragments = tmpinfo.hiwat -
@@ -398,12 +405,12 @@ oss_ioctl_audio(p, uap, retval)
tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.play.seek;
error = copyout(&bufinfo, SCARG(uap, data), sizeof bufinfo);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_GETISPACE:
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
- return error;
+ goto out;
setblocksize(fp, &tmpinfo, p);
bufinfo.fragsize = tmpinfo.blocksize;
bufinfo.fragments = tmpinfo.hiwat -
@@ -417,18 +424,18 @@ oss_ioctl_audio(p, uap, retval)
bufinfo.fragstotal, bufinfo.bytes));
error = copyout(&bufinfo, SCARG(uap, data), sizeof bufinfo);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_NONBLOCK:
idat = 1;
error = ioctlf(fp, FIONBIO, (caddr_t)&idat, p);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_GETCAPS:
error = ioctlf(fp, AUDIO_GETPROPS, (caddr_t)&idata, p);
if (error)
- return error;
+ goto out;
idat = OSS_DSP_CAP_TRIGGER; /* pretend we have trigger */
if (idata & AUDIO_PROP_FULLDUPLEX)
idat |= OSS_DSP_CAP_DUPLEX;
@@ -437,71 +444,78 @@ oss_ioctl_audio(p, uap, retval)
DPRINTF(("oss_sys_ioctl: SNDCTL_DSP_GETCAPS = %x\n", idat));
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
#if 0
case OSS_SNDCTL_DSP_GETTRIGGER:
error = ioctlf(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
if (error)
- return error;
+ goto out;
idat = (tmpinfo.play.pause ? 0 : OSS_PCM_ENABLE_OUTPUT) |
(tmpinfo.record.pause ? 0 : OSS_PCM_ENABLE_INPUT);
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_SETTRIGGER:
AUDIO_INITINFO(&tmpinfo);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
- return error;
+ goto out;
tmpinfo.play.pause = (idat & OSS_PCM_ENABLE_OUTPUT) == 0;
tmpinfo.record.pause = (idat & OSS_PCM_ENABLE_INPUT) == 0;
(void) ioctlf(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error)
- return error;
+ goto out;
break;
#else
case OSS_SNDCTL_DSP_GETTRIGGER:
case OSS_SNDCTL_DSP_SETTRIGGER:
/* XXX Do nothing for now. */
idat = OSS_PCM_ENABLE_OUTPUT;
- return copyout(&idat, SCARG(uap, data), sizeof idat);
+ error = copyout(&idat, SCARG(uap, data), sizeof idat);
+ goto out;
#endif
case OSS_SNDCTL_DSP_GETIPTR:
error = ioctlf(fp, AUDIO_GETIOFFS, (caddr_t)&tmpoffs, p);
if (error)
- return error;
+ goto out;
cntinfo.bytes = tmpoffs.samples;
cntinfo.blocks = tmpoffs.deltablks;
cntinfo.ptr = tmpoffs.offset;
error = copyout(&cntinfo, SCARG(uap, data), sizeof cntinfo);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_GETOPTR:
error = ioctlf(fp, AUDIO_GETOOFFS, (caddr_t)&tmpoffs, p);
if (error)
- return error;
+ goto out;
cntinfo.bytes = tmpoffs.samples;
cntinfo.blocks = tmpoffs.deltablks;
cntinfo.ptr = tmpoffs.offset;
error = copyout(&cntinfo, SCARG(uap, data), sizeof cntinfo);
if (error)
- return error;
+ goto out;
break;
case OSS_SNDCTL_DSP_MAPINBUF:
case OSS_SNDCTL_DSP_MAPOUTBUF:
case OSS_SNDCTL_DSP_SETSYNCRO:
case OSS_SNDCTL_DSP_SETDUPLEX:
case OSS_SNDCTL_DSP_PROFILE:
- return EINVAL; /* XXX unimplemented */
+ error = EINVAL; /* XXX unimplemented */
+ goto out;
default:
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
- return 0;
+ error = 0;
+
+out:
+ FRELE(fp);
+ return (error);
}
/* If the NetBSD mixer device should have more than 32 devices
@@ -653,28 +667,35 @@ oss_ioctl_mixer(p, uap, retval)
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
return (EBADF);
+ FREF(fp);
- if ((fp->f_flag & (FREAD | FWRITE)) == 0)
- return (EBADF);
+ if ((fp->f_flag & (FREAD | FWRITE)) == 0) {
+ error = EBADF;
+ goto out;
+ }
com = SCARG(uap, com);
retval[0] = 0;
di = getdevinfo(fp, p);
- if (di == 0)
- return EINVAL;
+ if (di == 0) {
+ error = EINVAL;
+ goto out;
+ }
ioctlf = fp->f_ops->fo_ioctl;
switch (com) {
case OSS_SOUND_MIXER_READ_RECSRC:
- if (di->source == -1)
- return EINVAL;
+ if (di->source == -1) {
+ error = EINVAL;
+ goto out;
+ }
mc.dev = di->source;
if (di->caps & OSS_SOUND_CAP_EXCL_INPUT) {
mc.type = AUDIO_MIXER_ENUM;
error = ioctlf(fp, AUDIO_MIXER_READ, (caddr_t)&mc, p);
if (error)
- return error;
+ goto out;
idat = 1 << di->rdevmap[mc.un.ord];
} else {
int k;
@@ -682,7 +703,7 @@ oss_ioctl_mixer(p, uap, retval)
mc.type = AUDIO_MIXER_SET;
error = ioctlf(fp, AUDIO_MIXER_READ, (caddr_t)&mc, p);
if (error)
- return error;
+ goto out;
idat = 0;
for(mask = mc.un.mask, k = 0; mask; mask >>= 1, k++)
if (mask & 1)
@@ -703,46 +724,55 @@ oss_ioctl_mixer(p, uap, retval)
break;
case OSS_SOUND_MIXER_WRITE_RECSRC:
case OSS_SOUND_MIXER_WRITE_R_RECSRC:
- if (di->source == -1)
- return EINVAL;
+ if (di->source == -1) {
+ error = EINVAL;
+ goto out;
+ }
mc.dev = di->source;
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
- return error;
+ goto out;
if (di->caps & OSS_SOUND_CAP_EXCL_INPUT) {
mc.type = AUDIO_MIXER_ENUM;
for(i = 0; i < OSS_SOUND_MIXER_NRDEVICES; i++)
if (idat & (1 << i))
break;
if (i >= OSS_SOUND_MIXER_NRDEVICES ||
- di->devmap[i] == -1)
- return EINVAL;
+ di->devmap[i] == -1) {
+ error = EINVAL;
+ goto out;
+ }
mc.un.ord = di->devmap[i];
} else {
mc.type = AUDIO_MIXER_SET;
mc.un.mask = 0;
for(i = 0; i < OSS_SOUND_MIXER_NRDEVICES; i++) {
if (idat & (1 << i)) {
- if (di->devmap[i] == -1)
- return EINVAL;
+ if (di->devmap[i] == -1) {
+ error = EINVAL;
+ goto out;
+ }
mc.un.mask |= 1 << di->devmap[i];
}
}
}
- return ioctlf(fp, AUDIO_MIXER_WRITE, (caddr_t)&mc, p);
+ error = ioctlf(fp, AUDIO_MIXER_WRITE, (caddr_t)&mc, p);
+ goto out;
default:
if (OSS_MIXER_READ(OSS_SOUND_MIXER_FIRST) <= com &&
com < OSS_MIXER_READ(OSS_SOUND_MIXER_NRDEVICES)) {
n = OSS_GET_DEV(com);
- if (di->devmap[n] == -1)
- return EINVAL;
+ if (di->devmap[n] == -1) {
+ error = EINVAL;
+ goto out;
+ }
doread:
mc.dev = di->devmap[n];
mc.type = AUDIO_MIXER_VALUE;
mc.un.value.num_channels = di->stereomask & (1<<n) ? 2 : 1;
error = ioctlf(fp, AUDIO_MIXER_READ, (caddr_t)&mc, p);
if (error)
- return error;
+ goto out;
if (mc.un.value.num_channels != 2) {
l = r = mc.un.value.level[AUDIO_MIXER_LEVEL_MONO];
} else {
@@ -758,11 +788,13 @@ oss_ioctl_mixer(p, uap, retval)
(OSS_MIXER_WRITE(OSS_SOUND_MIXER_FIRST) <= com &&
com < OSS_MIXER_WRITE(OSS_SOUND_MIXER_NRDEVICES))) {
n = OSS_GET_DEV(com);
- if (di->devmap[n] == -1)
- return EINVAL;
+ if (di->devmap[n] == -1) {
+ error = EINVAL;
+ goto out;
+ }
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error)
- return error;
+ goto out;
l = FROM_OSSVOL( idat & 0xff);
r = FROM_OSSVOL((idat >> 8) & 0xff);
mc.dev = di->devmap[n];
@@ -779,19 +811,26 @@ oss_ioctl_mixer(p, uap, retval)
n, di->devmap[n], l, r, idat));
error = ioctlf(fp, AUDIO_MIXER_WRITE, (caddr_t)&mc, p);
if (error)
- return error;
+ goto out;
if (OSS_MIXER_WRITE(OSS_SOUND_MIXER_FIRST) <= com &&
- com < OSS_MIXER_WRITE(OSS_SOUND_MIXER_NRDEVICES))
- return 0;
+ com < OSS_MIXER_WRITE(OSS_SOUND_MIXER_NRDEVICES)) {
+ error = 0;
+ goto out;
+ }
goto doread;
} else {
#ifdef AUDIO_DEBUG
printf("oss_audio: unknown mixer ioctl %04lx\n", com);
#endif
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
}
- return copyout(&idat, SCARG(uap, data), sizeof idat);
+ error = copyout(&idat, SCARG(uap, data), sizeof idat);
+
+out:
+ FRELE(fp);
+ return (error);
}
/* XXX hook for sequencer emulation */
diff --git a/sys/compat/sunos/sunos_ioctl.c b/sys/compat/sunos/sunos_ioctl.c
index a3d3c0f4702..fa93293fb93 100644
--- a/sys/compat/sunos/sunos_ioctl.c
+++ b/sys/compat/sunos/sunos_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunos_ioctl.c,v 1.11 2001/10/26 12:03:27 art Exp $ */
+/* $OpenBSD: sunos_ioctl.c,v 1.12 2002/02/14 22:57:18 pvalchev Exp $ */
/* $NetBSD: sunos_ioctl.c,v 1.23 1996/03/14 19:33:46 christos Exp $ */
/*
@@ -399,16 +399,19 @@ sunos_sys_ioctl(p, v, retval)
register_t *retval;
{
struct sunos_sys_ioctl_args *uap = v;
- register struct filedesc *fdp = p->p_fd;
- register struct file *fp;
- register int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *));
+ struct filedesc *fdp = p->p_fd;
+ struct file *fp;
+ int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *));
int error;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
return EBADF;
+ FREF(fp);
- if ((fp->f_flag & (FREAD|FWRITE)) == 0)
- return EBADF;
+ if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
+ error = EBADF;
+ goto out;
+ }
ctl = fp->f_ops->fo_ioctl;
@@ -422,33 +425,39 @@ sunos_sys_ioctl(p, v, retval)
if ((error = copyin(SCARG(uap, data), (caddr_t)&disc,
sizeof disc)) != 0)
- return error;
+ goto out;
/* map SunOS NTTYDISC into our termios discipline */
if (disc == 2)
disc = 0;
/* all other disciplines are not supported by NetBSD */
- if (disc)
- return ENXIO;
+ if (disc) {
+ error = ENXIO;
+ goto out;
+ }
- return (*ctl)(fp, TIOCSETD, (caddr_t)&disc, p);
+ error = (*ctl)(fp, TIOCSETD, (caddr_t)&disc, p);
+ goto out;
}
case _IOW('t', 101, int): /* sun SUNOS_TIOCSSOFTCAR */
{
int x; /* unused */
- return copyin((caddr_t)&x, SCARG(uap, data), sizeof x);
+ error = copyin((caddr_t)&x, SCARG(uap, data), sizeof x);
+ goto out;
}
case _IOR('t', 100, int): /* sun SUNOS_TIOCGSOFTCAR */
{
int x = 0;
- return copyout((caddr_t)&x, SCARG(uap, data), sizeof x);
+ error = copyout((caddr_t)&x, SCARG(uap, data), sizeof x);
+ goto out;
}
case _IO('t', 36): /* sun TIOCCONS, no parameters */
{
int on = 1;
- return (*ctl)(fp, TIOCCONS, (caddr_t)&on, p);
+ error = (*ctl)(fp, TIOCCONS, (caddr_t)&on, p);
+ goto out;
}
case _IOW('t', 37, struct sunos_ttysize):
{
@@ -456,15 +465,16 @@ sunos_sys_ioctl(p, v, retval)
struct sunos_ttysize ss;
if ((error = (*ctl)(fp, TIOCGWINSZ, (caddr_t)&ws, p)) != 0)
- return (error);
+ goto out;
if ((error = copyin (SCARG(uap, data), &ss, sizeof (ss))) != 0)
- return error;
+ goto out;
ws.ws_row = ss.ts_row;
ws.ws_col = ss.ts_col;
- return ((*ctl)(fp, TIOCSWINSZ, (caddr_t)&ws, p));
+ error = ((*ctl)(fp, TIOCSWINSZ, (caddr_t)&ws, p));
+ goto out;
}
case _IOW('t', 38, struct sunos_ttysize):
{
@@ -472,12 +482,13 @@ sunos_sys_ioctl(p, v, retval)
struct sunos_ttysize ss;
if ((error = (*ctl)(fp, TIOCGWINSZ, (caddr_t)&ws, p)) != 0)
- return (error);
+ goto out;
ss.ts_row = ws.ws_row;
ss.ts_col = ws.ws_col;
- return copyout ((caddr_t)&ss, SCARG(uap, data), sizeof (ss));
+ error = copyout ((caddr_t)&ss, SCARG(uap, data), sizeof (ss));
+ goto out;
}
case _IOW('t', 130, int): /* TIOCSETPGRP: posix variant */
SCARG(uap, com) = TIOCSPGRP;
@@ -496,16 +507,18 @@ sunos_sys_ioctl(p, v, retval)
if (error == EIO && vp != NULL &&
vp->v_type == VCHR && major(vp->v_rdev) == 21)
error = ENOTTY;
- return (error);
+ goto out;
}
- return copyout((caddr_t)&pgrp, SCARG(uap, data), sizeof(pgrp));
+ error = copyout((caddr_t)&pgrp, SCARG(uap, data), sizeof(pgrp));
+ goto out;
}
case _IO('t', 132):
SCARG(uap, com) = TIOCSCTTY;
break;
case SUNOS_TCFLSH:
/* XXX: fixme */
- return (0);
+ error = 0;
+ goto out;
case SUNOS_TCGETA:
case SUNOS_TCGETS:
{
@@ -514,16 +527,19 @@ sunos_sys_ioctl(p, v, retval)
struct sunos_termio st;
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0)
- return error;
+ goto out;
btios2stios (&bts, &sts);
if (SCARG(uap, com) == SUNOS_TCGETA) {
stios2stio (&sts, &st);
- return copyout((caddr_t)&st, SCARG(uap, data),
+ error = copyout((caddr_t)&st, SCARG(uap, data),
sizeof (st));
- } else
- return copyout((caddr_t)&sts, SCARG(uap, data),
+ goto out;
+ } else {
+ error = copyout((caddr_t)&sts, SCARG(uap, data),
sizeof (sts));
+ goto out;
+ }
/*NOTREACHED*/
}
case SUNOS_TCSETA:
@@ -536,11 +552,11 @@ sunos_sys_ioctl(p, v, retval)
if ((error = copyin(SCARG(uap, data), (caddr_t)&st,
sizeof (st))) != 0)
- return error;
+ goto out;
/* get full BSD termios so we don't lose information */
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0)
- return error;
+ goto out;
/*
* convert to sun termios, copy in information from
@@ -550,8 +566,9 @@ sunos_sys_ioctl(p, v, retval)
stio2stios(&st, &sts);
stios2btios(&sts, &bts);
- return (*ctl)(fp, SCARG(uap, com) - SUNOS_TCSETA + TIOCSETA,
+ error = (*ctl)(fp, SCARG(uap, com) - SUNOS_TCSETA + TIOCSETA,
(caddr_t)&bts, p);
+ goto out;
}
case SUNOS_TCSETS:
case SUNOS_TCSETSW:
@@ -562,10 +579,11 @@ sunos_sys_ioctl(p, v, retval)
if ((error = copyin (SCARG(uap, data), (caddr_t)&sts,
sizeof (sts))) != 0)
- return error;
+ goto out;
stios2btios (&sts, &bts);
- return (*ctl)(fp, SCARG(uap, com) - SUNOS_TCSETS + TIOCSETA,
+ error = (*ctl)(fp, SCARG(uap, com) - SUNOS_TCSETS + TIOCSETA,
(caddr_t)&bts, p);
+ goto out;
}
/*
* Pseudo-tty ioctl translations.
@@ -575,16 +593,18 @@ sunos_sys_ioctl(p, v, retval)
error = copyin (SCARG(uap, data), (caddr_t)&on, sizeof (on));
if (error)
- return error;
- return (*ctl)(fp, TIOCUCNTL, (caddr_t)&on, p);
+ goto out;
+ error = (*ctl)(fp, TIOCUCNTL, (caddr_t)&on, p);
+ goto out;
}
case _IOW('t', 33, int): { /* TIOCSIGNAL */
int error, sig;
error = copyin (SCARG(uap, data), (caddr_t)&sig, sizeof (sig));
if (error)
- return error;
- return (*ctl)(fp, TIOCSIG, (caddr_t)&sig, p);
+ goto out;
+ error = (*ctl)(fp, TIOCSIG, (caddr_t)&sig, p);
+ goto out;
}
/*
@@ -594,17 +614,19 @@ sunos_sys_ioctl(p, v, retval)
struct ifreq ifreq; \
error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq)); \
if (error) \
- return error; \
- return (*ctl)(fp, a, (caddr_t)&ifreq, p); \
+ goto out; \
+ error = (*ctl)(fp, a, (caddr_t)&ifreq, p); \
+ goto out; \
}
#define IFREQ_INOUT(a) { \
struct ifreq ifreq; \
error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq)); \
if (error) \
- return error; \
+ goto out; \
if ((error = (*ctl)(fp, a, (caddr_t)&ifreq, p)) != 0) \
- return error; \
- return copyout ((caddr_t)&ifreq, SCARG(uap, data), sizeof (ifreq)); \
+ goto out; \
+ error = copyout ((caddr_t)&ifreq, SCARG(uap, data), sizeof (ifreq)); \
+ goto out; \
}
case _IOW('i', 12, struct ifreq):
@@ -676,7 +698,8 @@ sunos_sys_ioctl(p, v, retval)
case _IOW('i', 48, int): /* SIOCSPROMISC */
case _IOW('i', 49, struct ifreq): /* SIOCADDMULTI */
case _IOW('i', 50, struct ifreq): /* SIOCDELMULTI */
- return EOPNOTSUPP;
+ error = EOPNOTSUPP;
+ goto out;
case _IOWR('i', 20, struct ifconf): /* SIOCGIFCONF */
{
@@ -690,12 +713,13 @@ sunos_sys_ioctl(p, v, retval)
error = copyin (SCARG(uap, data), (caddr_t)&ifconf,
sizeof (ifconf));
if (error)
- return error;
+ goto out;
error = (*ctl)(fp, OSIOCGIFCONF, (caddr_t)&ifconf, p);
if (error)
- return error;
- return copyout ((caddr_t)&ifconf, SCARG(uap, data),
+ goto out;
+ error = copyout ((caddr_t)&ifconf, SCARG(uap, data),
sizeof (ifconf));
+ goto out;
}
/*
@@ -709,7 +733,7 @@ sunos_sys_ioctl(p, v, retval)
error = (*ctl)(fp, AUDIO_GETINFO, (caddr_t)&aui, p);
if (error)
- return error;
+ goto out;
sunos_aui.play = *(struct sunos_audio_prinfo *)&aui.play;
sunos_aui.record = *(struct sunos_audio_prinfo *)&aui.record;
@@ -729,8 +753,9 @@ sunos_sys_ioctl(p, v, retval)
/*XXX*/sunos_aui.reserved[2] = 0;
/*XXX*/sunos_aui.reserved[3] = 0;
- return copyout ((caddr_t)&sunos_aui, SCARG(uap, data),
+ error = copyout ((caddr_t)&sunos_aui, SCARG(uap, data),
sizeof (sunos_aui));
+ goto out;
}
case _IOWR('A', 2, struct sunos_audio_info): /* AUDIO_SETINFO */
@@ -741,7 +766,7 @@ sunos_sys_ioctl(p, v, retval)
error = copyin (SCARG(uap, data), (caddr_t)&sunos_aui,
sizeof (sunos_aui));
if (error)
- return error;
+ goto out;
aui.play = *(struct audio_prinfo *)&sunos_aui.play;
aui.record = *(struct audio_prinfo *)&sunos_aui.record;
@@ -772,17 +797,19 @@ sunos_sys_ioctl(p, v, retval)
error = (*ctl)(fp, AUDIO_SETINFO, (caddr_t)&aui, p);
if (error)
- return error;
+ goto out;
/* Return new state */
goto sunos_au_getinfo;
}
case _IO('A', 3): /* AUDIO_DRAIN */
- return (*ctl)(fp, AUDIO_DRAIN, (void *)0, p);
+ error = (*ctl)(fp, AUDIO_DRAIN, (void *)0, p);
+ goto out;
case _IOR('A', 4, int): /* AUDIO_GETDEV */
{
int devtype = SUNOS_AUDIO_DEV_AMD;
- return copyout ((caddr_t)&devtype, SCARG(uap, data),
+ error = copyout ((caddr_t)&devtype, SCARG(uap, data),
sizeof (devtype));
+ goto out;
}
/*
@@ -811,19 +838,26 @@ sunos_sys_ioctl(p, v, retval)
tmp = FREAD|FWRITE;
break;
}
- return (*ctl)(fp, TIOCFLUSH, (caddr_t)&tmp, p);
+ error = (*ctl)(fp, TIOCFLUSH, (caddr_t)&tmp, p);
+ goto out;
}
case _IO('S', 9): /* I_SETSIG */
{
int on = 1;
if (((int)SCARG(uap, data) & (SUNOS_S_HIPRI|SUNOS_S_INPUT)) ==
- SUNOS_S_HIPRI)
- return EOPNOTSUPP;
- return (*ctl)(fp, FIOASYNC, (caddr_t)&on, p);
+ SUNOS_S_HIPRI) {
+ error = EOPNOTSUPP;
+ goto out;
+ }
+ error = (*ctl)(fp, FIOASYNC, (caddr_t)&on, p);
+ goto out;
}
}
- return (sys_ioctl(p, uap, retval));
+ error = (sys_ioctl(p, uap, retval));
+out:
+ FRELE(fp);
+ return (error);
}
/* SunOS fcntl(2) cmds not implemented */
diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c
index 2f3cd8e7d32..09828a6ffce 100644
--- a/sys/compat/svr4/svr4_stream.c
+++ b/sys/compat/svr4/svr4_stream.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_stream.c,v 1.15 2002/02/13 19:08:06 art Exp $ */
+/* $OpenBSD: svr4_stream.c,v 1.16 2002/02/14 22:57:18 pvalchev Exp $ */
/* $NetBSD: svr4_stream.c,v 1.19 1996/12/22 23:00:03 fvdl Exp $ */
/*
@@ -1428,17 +1428,18 @@ svr4_sys_putmsg(p, v, retval)
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
return EBADF;
+ FREF(fp);
if (SCARG(uap, ctl) != NULL) {
if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0)
- return error;
+ goto out;
}
else
ctl.len = -1;
if (SCARG(uap, dat) != NULL) {
if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0)
- return error;
+ goto out;
}
else
dat.len = -1;
@@ -1448,23 +1449,26 @@ svr4_sys_putmsg(p, v, retval)
*/
if ((st = svr4_stream_get(fp)) == NULL) {
DPRINTF(("putmsg: bad file type\n"));
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
if (ctl.len > sizeof(sc)) {
DPRINTF(("putmsg: Bad control size %d != %d\n", ctl.len,
sizeof(struct svr4_strmcmd)));
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)
- return error;
+ goto out;
switch (st->s_family) {
case AF_INET:
if (sc.len != sizeof(sain)) {
DPRINTF(("putmsg: Invalid inet length %ld\n", sc.len));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
netaddr_to_sockaddr_in(&sain, &sc);
skp = &sain;
@@ -1477,7 +1481,8 @@ svr4_sys_putmsg(p, v, retval)
/* We are doing an accept; succeed */
DPRINTF(("putmsg: Do nothing\n"));
*retval = 0;
- return 0;
+ error = 0;
+ goto out;
} else {
/* Maybe we've been given a device/inode pair */
dev_t *dev = SVR4_ADDROF(&sc);
@@ -1495,14 +1500,15 @@ svr4_sys_putmsg(p, v, retval)
default:
DPRINTF(("putmsg: Unsupported address family %d\n",
st->s_family));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
sg = stackgap_init(p->p_emul);
sup = stackgap_alloc(&sg, sasize);
if ((error = copyout(skp, sup, sasize)) != 0)
- return error;
+ goto out;
switch (st->s_cmd = sc.cmd) {
case SVR4_TI_CONNECT_REQUEST: /* connect */
@@ -1512,7 +1518,8 @@ svr4_sys_putmsg(p, v, retval)
SCARG(&co, s) = SCARG(uap, fd);
SCARG(&co, name) = (void *)sup;
SCARG(&co, namelen) = (int)sasize;
- return sys_connect(p, &co, retval);
+ error = sys_connect(p, &co, retval);
+ goto out;
}
case SVR4_TI_SENDTO_REQUEST: /* sendto */
@@ -1532,13 +1539,18 @@ svr4_sys_putmsg(p, v, retval)
SCARG(uap, flags), retval);
*retval = 0;
- return error;
+ goto out;
}
default:
DPRINTF(("putmsg: Unimplemented command %lx\n", sc.cmd));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
+
+out:
+ FRELE(fp);
+ return (error);
}
@@ -1576,10 +1588,11 @@ svr4_sys_getmsg(p, v, retval)
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
return EBADF;
+ FREF(fp);
if (SCARG(uap, ctl) != NULL) {
if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0)
- return error;
+ goto out;
}
else {
ctl.len = -1;
@@ -1588,7 +1601,7 @@ svr4_sys_getmsg(p, v, retval)
if (SCARG(uap, dat) != NULL) {
if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0)
- return error;
+ goto out;
}
else {
dat.len = -1;
@@ -1600,12 +1613,14 @@ svr4_sys_getmsg(p, v, retval)
*/
if ((st = svr4_stream_get(fp)) == NULL) {
DPRINTF(("getmsg: bad file type\n"));
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
if (ctl.maxlen == -1 || dat.maxlen == -1) {
DPRINTF(("getmsg: Cannot handle -1 maxlen (yet)\n"));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
switch (st->s_family) {
@@ -1622,7 +1637,8 @@ svr4_sys_getmsg(p, v, retval)
default:
DPRINTF(("getmsg: Unsupported address family %d\n",
st->s_family));
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
sg = stackgap_init(p->p_emul);
@@ -1631,7 +1647,7 @@ svr4_sys_getmsg(p, v, retval)
fl = sasize;
if ((error = copyout(&fl, flen, sizeof(fl))) != 0)
- return error;
+ goto out;
switch (st->s_cmd) {
case SVR4_TI_CONNECT_REQUEST:
@@ -1662,11 +1678,11 @@ svr4_sys_getmsg(p, v, retval)
if ((error = sys_getpeername(p, &ga, retval)) != 0) {
DPRINTF(("getmsg: getpeername failed %d\n", error));
- return error;
+ goto out;
}
if ((error = copyin(sup, skp, sasize)) != 0)
- return error;
+ goto out;
sc.cmd = SVR4_TI_CONNECT_REPLY;
sc.pad[0] = 0x4;
@@ -1686,7 +1702,8 @@ svr4_sys_getmsg(p, v, retval)
break;
default:
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
ctl.len = 40;
@@ -1721,7 +1738,7 @@ svr4_sys_getmsg(p, v, retval)
if ((error = sys_accept(p, &aa, retval)) != 0) {
DPRINTF(("getmsg: accept failed %d\n", error));
- return error;
+ goto out;
}
st->s_afd = *retval;
@@ -1729,7 +1746,7 @@ svr4_sys_getmsg(p, v, retval)
DPRINTF(("getmsg: Accept fd = %d\n", st->s_afd));
if ((error = copyin(sup, skp, sasize)) != 0)
- return error;
+ goto out;
sc.cmd = SVR4_TI_ACCEPT_REPLY;
sc.len = sasize;
@@ -1755,7 +1772,8 @@ svr4_sys_getmsg(p, v, retval)
break;
default:
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
ctl.len = 40;
@@ -1773,7 +1791,7 @@ svr4_sys_getmsg(p, v, retval)
ctl.len = sizeof(sc);
if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)
- return error;
+ goto out;
switch (st->s_family) {
case AF_INET:
@@ -1785,7 +1803,8 @@ svr4_sys_getmsg(p, v, retval)
break;
default:
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
msg.msg_name = (caddr_t) sup;
@@ -1801,11 +1820,11 @@ svr4_sys_getmsg(p, v, retval)
if (error) {
DPRINTF(("getmsg: recvit failed %d\n", error));
- return error;
+ goto out;
}
if ((error = copyin(msg.msg_name, skp, sasize)) != 0)
- return error;
+ goto out;
sc.cmd = SVR4_TI_RECVFROM_REPLY;
@@ -1821,7 +1840,8 @@ svr4_sys_getmsg(p, v, retval)
break;
default:
- return ENOSYS;
+ error = ENOSYS;
+ goto out;
}
dat.len = *retval;
@@ -1832,26 +1852,27 @@ svr4_sys_getmsg(p, v, retval)
default:
st->s_cmd = sc.cmd;
DPRINTF(("getmsg: Unknown state %x\n", st->s_cmd));
- return EINVAL;
+ error = EINVAL;
+ goto out;
}
if (SCARG(uap, ctl)) {
if (ctl.len != -1)
if ((error = copyout(&sc, ctl.buf, ctl.len)) != 0)
- return error;
+ goto out;
if ((error = copyout(&ctl, SCARG(uap, ctl), sizeof(ctl))) != 0)
- return error;
+ goto out;
}
if (SCARG(uap, dat)) {
if ((error = copyout(&dat, SCARG(uap, dat), sizeof(dat))) != 0)
- return error;
+ goto out;
}
if (SCARG(uap, flags)) { /* XXX: Need translation */
if ((error = copyout(&fl, SCARG(uap, flags), sizeof(fl))) != 0)
- return error;
+ goto out;
}
*retval = 0;
@@ -1860,5 +1881,7 @@ svr4_sys_getmsg(p, v, retval)
show_msg("<getmsg", SCARG(uap, fd), SCARG(uap, ctl),
SCARG(uap, dat), fl);
#endif /* DEBUG_SVR4 */
+out:
+ FRELE(fp);
return error;
}
diff --git a/sys/compat/ultrix/ultrix_ioctl.c b/sys/compat/ultrix/ultrix_ioctl.c
index 4c80fc8f5f7..71bf9544e8c 100644
--- a/sys/compat/ultrix/ultrix_ioctl.c
+++ b/sys/compat/ultrix/ultrix_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ultrix_ioctl.c,v 1.8 2001/10/26 12:03:27 art Exp $ */
+/* $OpenBSD: ultrix_ioctl.c,v 1.9 2002/02/14 22:57:18 pvalchev Exp $ */
/* $NetBSD: ultrix_ioctl.c,v 1.3.4.1 1996/06/13 18:22:37 jonathan Exp $ */
/* from : NetBSD: sunos_ioctl.c,v 1.21 1995/10/07 06:27:31 mycroft Exp */
@@ -444,16 +444,19 @@ ultrix_sys_ioctl(p, v, retval)
register_t *retval;
{
struct ultrix_sys_ioctl_args *uap = v;
- register struct filedesc *fdp = p->p_fd;
- register struct file *fp;
+ struct filedesc *fdp = p->p_fd;
+ struct file *fp;
register int (*ctl)();
int error;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
return EBADF;
+ FREF(fp);
- if ((fp->f_flag & (FREAD|FWRITE)) == 0)
- return EBADF;
+ if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
+ error = EBADF;
+ goto out;
+ }
ctl = fp->f_ops->fo_ioctl;
@@ -467,33 +470,39 @@ ultrix_sys_ioctl(p, v, retval)
if ((error = copyin(SCARG(uap, data), (caddr_t)&disc,
sizeof disc)) != 0)
- return error;
+ goto out;
/* map SunOS NTTYDISC into our termios discipline */
if (disc == 2)
disc = 0;
/* all other disciplines are not supported by NetBSD */
- if (disc)
- return ENXIO;
+ if (disc) {
+ error = ENXIO;
+ goto out;
+ }
- return (*ctl)(fp, TIOCSETD, (caddr_t)&disc, p);
+ error = (*ctl)(fp, TIOCSETD, (caddr_t)&disc, p);
+ goto out;
}
case _IOW('t', 101, int): /* sun SUNOS_TIOCSSOFTCAR */
{
int x; /* unused */
- return copyin((caddr_t)&x, SCARG(uap, data), sizeof x);
+ error = copyin((caddr_t)&x, SCARG(uap, data), sizeof x);
+ goto out;
}
case _IOR('t', 100, int): /* sun SUNOS_TIOCSSOFTCAR */
{
int x = 0;
- return copyout((caddr_t)&x, SCARG(uap, data), sizeof x);
+ error = copyout((caddr_t)&x, SCARG(uap, data), sizeof x);
+ goto out;
}
case _IO('t', 36): /* sun TIOCCONS, no parameters */
{
int on = 1;
- return (*ctl)(fp, TIOCCONS, (caddr_t)&on, p);
+ error = (*ctl)(fp, TIOCCONS, (caddr_t)&on, p);
+ goto out;
}
case _IOW('t', 37, struct sunos_ttysize):
{
@@ -501,15 +510,16 @@ ultrix_sys_ioctl(p, v, retval)
struct sunos_ttysize ss;
if ((error = (*ctl)(fp, TIOCGWINSZ, (caddr_t)&ws, p)) != 0)
- return (error);
+ goto out;
if ((error = copyin (SCARG(uap, data), &ss, sizeof (ss))) != 0)
- return error;
+ goto out;
ws.ws_row = ss.ts_row;
ws.ws_col = ss.ts_col;
- return ((*ctl)(fp, TIOCSWINSZ, (caddr_t)&ws, p));
+ error = ((*ctl)(fp, TIOCSWINSZ, (caddr_t)&ws, p));
+ goto out;
}
case _IOW('t', 38, struct sunos_ttysize):
{
@@ -517,12 +527,13 @@ ultrix_sys_ioctl(p, v, retval)
struct sunos_ttysize ss;
if ((error = (*ctl)(fp, TIOCGWINSZ, (caddr_t)&ws, p)) != 0)
- return (error);
+ goto out;
ss.ts_row = ws.ws_row;
ss.ts_col = ws.ws_col;
- return copyout ((caddr_t)&ss, SCARG(uap, data), sizeof (ss));
+ error = copyout ((caddr_t)&ss, SCARG(uap, data), sizeof (ss));
+ goto out;
}
case _IOW('t', 130, int):
SCARG(uap, com) = TIOCSPGRP;
@@ -542,16 +553,19 @@ ultrix_sys_ioctl(p, v, retval)
struct ultrix_termio st;
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0)
- return error;
+ goto out;
btios2stios (&bts, &sts);
if (SCARG(uap, com) == ULTRIX_TCGETA) {
stios2stio (&sts, &st);
- return copyout((caddr_t)&st, SCARG(uap, data),
+ error = copyout((caddr_t)&st, SCARG(uap, data),
sizeof (st));
- } else
- return copyout((caddr_t)&sts, SCARG(uap, data),
+ goto out;
+ } else {
+ error = copyout((caddr_t)&sts, SCARG(uap, data),
sizeof (sts));
+ goto out;
+ }
/*NOTREACHED*/
}
/* Emulate termio tcset() */
@@ -562,15 +576,14 @@ ultrix_sys_ioctl(p, v, retval)
struct termios bts;
struct ultrix_termios sts;
struct ultrix_termio st;
- int result;
if ((error = copyin(SCARG(uap, data), (caddr_t)&st,
sizeof (st))) != 0)
- return error;
+ goto out;
/* get full BSD termios so we don't lose information */
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0)
- return error;
+ goto out;
/*
* convert to sun termios, copy in information from
@@ -583,17 +596,11 @@ ultrix_sys_ioctl(p, v, retval)
/*
* map ioctl code: ultrix tcsets are numbered in reverse order
*/
-#ifdef notyet
- return (*ctl)(fp, ULTRIX_TCSETA - SCARG(uap, com) + TIOCSETA,
- (caddr_t)&bts, p);
-#else
- result= (*ctl)(fp, ULTRIX_TCSETA - SCARG(uap, com) + TIOCSETA,
+ error = (*ctl)(fp, ULTRIX_TCSETA - SCARG(uap, com) + TIOCSETA,
(caddr_t)&bts, p);
printf("ultrix TCSETA %lx returns %d\n",
- ULTRIX_TCSETA - SCARG(uap, com), result);
- return result;
-#endif
-
+ ULTRIX_TCSETA - SCARG(uap, com), error);
+ goto out;
}
/* Emulate termios tcset() */
case ULTRIX_TCSETS:
@@ -605,10 +612,11 @@ ultrix_sys_ioctl(p, v, retval)
if ((error = copyin (SCARG(uap, data), (caddr_t)&sts,
sizeof (sts))) != 0)
- return error;
+ goto out;
stios2btios (&sts, &bts);
- return (*ctl)(fp, ULTRIX_TCSETS - SCARG(uap, com) + TIOCSETA,
+ error = (*ctl)(fp, ULTRIX_TCSETS - SCARG(uap, com) + TIOCSETA,
(caddr_t)&bts, p);
+ goto out;
}
/*
* Pseudo-tty ioctl translations.
@@ -618,16 +626,18 @@ ultrix_sys_ioctl(p, v, retval)
error = copyin (SCARG(uap, data), (caddr_t)&on, sizeof (on));
if (error != 0)
- return error;
- return (*ctl)(fp, TIOCUCNTL, (caddr_t)&on, p);
+ goto out;
+ error = (*ctl)(fp, TIOCUCNTL, (caddr_t)&on, p);
+ goto out;
}
case _IOW('t', 33, int): { /* TIOCSIGNAL */
int error, sig;
error = copyin (SCARG(uap, data), (caddr_t)&sig, sizeof (sig));
if (error != 0)
- return error;
- return (*ctl)(fp, TIOCSIG, (caddr_t)&sig, p);
+ goto out;
+ error = (*ctl)(fp, TIOCSIG, (caddr_t)&sig, p);
+ goto out;
}
/*
@@ -637,35 +647,39 @@ ultrix_sys_ioctl(p, v, retval)
type_t localbuf; \
if ((error = copyin (SCARG(uap, data), \
(caddr_t)&localbuf, sizeof (type_t))) != 0) \
- return error; \
- return (*ctl)(fp, a, (caddr_t)&localbuf, p); \
+ goto out; \
+ error = (*ctl)(fp, a, (caddr_t)&localbuf, p); \
+ goto out; \
}
#define INOUT_TYPE(a, type_t) { \
type_t localbuf; \
if ((error = copyin (SCARG(uap, data), (caddr_t)&localbuf, \
sizeof (type_t))) != 0) \
- return error; \
+ goto out; \
if ((error = (*ctl)(fp, a, (caddr_t)&localbuf, p)) != 0) \
- return error; \
- return copyout ((caddr_t)&localbuf, SCARG(uap, data), sizeof (type_t)); \
+ goto out; \
+ error = copyout ((caddr_t)&localbuf, SCARG(uap, data), sizeof (type_t)); \
+ goto out; \
}
#define IFREQ_IN(a) { \
struct ifreq ifreq; \
if ((error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq))) != 0) \
- return error; \
- return (*ctl)(fp, a, (caddr_t)&ifreq, p); \
+ goto out; \
+ error = (*ctl)(fp, a, (caddr_t)&ifreq, p); \
+ goto out; \
}
#define IFREQ_INOUT(a) { \
struct ifreq ifreq; \
if ((error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq))) != 0) \
- return error; \
+ goto out;; \
if ((error = (*ctl)(fp, a, (caddr_t)&ifreq, p)) != 0) \
- return error; \
- return copyout ((caddr_t)&ifreq, SCARG(uap, data), sizeof (ifreq)); \
+ goto out; \
+ error = copyout ((caddr_t)&ifreq, SCARG(uap, data), sizeof (ifreq)); \
+ goto out; \
}
case _IOW('i', 12, struct ifreq):
@@ -737,7 +751,8 @@ ultrix_sys_ioctl(p, v, retval)
case _IOW('i', 48, int): /* SIOCSPROMISC */
case _IOW('i', 49, struct ifreq): /* SIOCADDMULTI */
case _IOW('i', 50, struct ifreq): /* SIOCDELMULTI */
- return EOPNOTSUPP;
+ error = EOPNOTSUPP;
+ goto out;
case _IOWR('i', 20, struct ifconf): /* SIOCGIFCONF */
{
@@ -750,14 +765,19 @@ ultrix_sys_ioctl(p, v, retval)
*/
if ((error = copyin (SCARG(uap, data), (caddr_t)&ifconf,
sizeof (ifconf))) != 0)
- return error;
+ goto out;
if ((error = (*ctl)(fp, OSIOCGIFCONF,
* (caddr_t)&ifconf, p)) !=0 )
- return error;
- return copyout ((caddr_t)&ifconf, SCARG(uap, data),
+ goto out;
+ error = copyout ((caddr_t)&ifconf, SCARG(uap, data),
sizeof (ifconf));
+ goto out;
}
}
- return (sys_ioctl(p, uap, retval));
+ error = (sys_ioctl(p, uap, retval));
+
+out:
+ FRELE(fp);
+ return (error);
}