diff options
author | jasoni <jasoni@cvs.openbsd.org> | 2002-02-13 20:43:43 +0000 |
---|---|---|
committer | jasoni <jasoni@cvs.openbsd.org> | 2002-02-13 20:43:43 +0000 |
commit | bf35937b57e42882b040c93002a687dc31959a43 (patch) | |
tree | fa4abc1b9b9bb6c96cd18fe8459d91afc3cdd84b /sys/compat | |
parent | 11a466004819077c21fa18f4d72ed89d83708382 (diff) |
FREF/FRELE where required due to fd_getfile.
- ok art@
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linux/linux_cdrom.c | 84 | ||||
-rw-r--r-- | sys/compat/linux/linux_socket.c | 14 | ||||
-rw-r--r-- | sys/compat/linux/linux_termios.c | 99 |
3 files changed, 110 insertions, 87 deletions
diff --git a/sys/compat/linux/linux_cdrom.c b/sys/compat/linux/linux_cdrom.c index cbcb0256082..21d1c28adac 100644 --- a/sys/compat/linux/linux_cdrom.c +++ b/sys/compat/linux/linux_cdrom.c @@ -1,5 +1,5 @@ -/* $OpenBSD: linux_cdrom.c,v 1.6 2001/10/26 12:03:27 art Exp $ */ +/* $OpenBSD: linux_cdrom.c,v 1.7 2002/02/13 20:43:42 jasoni Exp $ */ /* * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> * All rights reserved. @@ -67,17 +67,17 @@ bsd_addr_to_linux_addr(bsd, linux, format) int linux_ioctl_cdrom(p, v, retval) - register struct proc *p; + struct proc *p; void *v; register_t *retval; { - register struct linux_sys_ioctl_args /* { + struct linux_sys_ioctl_args /* { syscallarg(int) fd; syscallarg(u_long) com; syscallarg(caddr_t) data; } */ *uap = v; - register struct file *fp; - register struct filedesc *fdp; + struct file *fp; + struct filedesc *fdp; caddr_t sg; u_long com, arg; struct sys_ioctl_args ia; @@ -110,9 +110,12 @@ linux_ioctl_cdrom(p, v, 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; @@ -122,14 +125,15 @@ linux_ioctl_cdrom(p, v, retval) error = (*fp->f_ops->fo_ioctl)(fp, CDIOREADTOCHEADER, (caddr_t)&tmpb.th, p); if (error) - return error; + goto out; tmpl.th.cdth_trk0 = tmpb.th.starting_track; tmpl.th.cdth_trk1 = tmpb.th.ending_track; - return copyout(&tmpl, SCARG(uap, data), sizeof tmpl.th); + error = copyout(&tmpl, SCARG(uap, data), sizeof tmpl.th); + goto out; case LINUX_CDROMREADTOCENTRY: error = copyin(SCARG(uap, data), &tmpl.te, sizeof tmpl.te); if (error) - return error; + goto out; sg = stackgap_init(p->p_emul); @@ -143,9 +147,9 @@ linux_ioctl_cdrom(p, v, retval) error = (*fp->f_ops->fo_ioctl)(fp, CDIOREADTOCENTRYS, (caddr_t)&tmpb.tes, p); if (error) - return error; + goto out; if ((error = copyin(tmpb.tes.data, &data.te, sizeof data.te))) - return error; + goto out; tmpl.te.cdte_ctrl = data.te.control; tmpl.te.cdte_adr = data.te.addr_type; @@ -153,11 +157,12 @@ linux_ioctl_cdrom(p, v, retval) tmpl.te.cdte_datamode = CD_TRACK_INFO; bsd_addr_to_linux_addr(&data.te.addr, &tmpl.te.cdte_addr, tmpb.tes.address_format); - return copyout(&tmpl, SCARG(uap, data), sizeof tmpl.te); + error = copyout(&tmpl, SCARG(uap, data), sizeof tmpl.te); + goto out; case LINUX_CDROMSUBCHNL: error = copyin(SCARG(uap, data), &tmpl.sc, sizeof tmpl.sc); if (error) - return error; + goto out; sg = stackgap_init(p->p_emul); @@ -171,9 +176,9 @@ linux_ioctl_cdrom(p, v, retval) error = (*fp->f_ops->fo_ioctl)(fp, CDIOCREADSUBCHANNEL, (caddr_t)&tmpb.sc, p); if (error) - return error; + goto out; if ((error = copyin(tmpb.sc.data, &data.scinfo, sizeof data.scinfo))) - return error; + goto out; tmpl.sc.cdsc_audiostatus = data.scinfo.header.audio_status; tmpl.sc.cdsc_adr = data.scinfo.what.position.addr_type; @@ -187,22 +192,24 @@ linux_ioctl_cdrom(p, v, retval) &tmpl.sc.cdsc_reladdr, tmpb.sc.address_format); - return copyout(&tmpl, SCARG(uap, data), sizeof tmpl.sc); + error = copyout(&tmpl, SCARG(uap, data), sizeof tmpl.sc); + goto out; case LINUX_CDROMPLAYTRKIND: error = copyin(SCARG(uap, data), &tmpl.ti, sizeof tmpl.ti); if (error) - return error; + goto out; tmpb.ti.start_track = tmpl.ti.cdti_trk0; tmpb.ti.start_index = tmpl.ti.cdti_ind0; tmpb.ti.end_track = tmpl.ti.cdti_trk1; tmpb.ti.end_index = tmpl.ti.cdti_ind1; - return (*fp->f_ops->fo_ioctl)(fp, CDIOCPLAYTRACKS, - (caddr_t)&tmpb.ti, p); + error = (*fp->f_ops->fo_ioctl)(fp, CDIOCPLAYTRACKS, + (caddr_t)&tmpb.ti, p); + goto out; case LINUX_CDROMPLAYMSF: error = copyin(SCARG(uap, data), &tmpl.msf, sizeof tmpl.msf); if (error) - return error; + goto out; tmpb.msf.start_m = tmpl.msf.cdmsf_min0; tmpb.msf.start_s = tmpl.msf.cdmsf_sec0; @@ -211,38 +218,46 @@ linux_ioctl_cdrom(p, v, retval) tmpb.msf.end_s = tmpl.msf.cdmsf_sec1; tmpb.msf.end_f = tmpl.msf.cdmsf_frame1; - return (*fp->f_ops->fo_ioctl)(fp, CDIOCPLAYMSF, (caddr_t)&tmpb.msf, p); + error = (*fp->f_ops->fo_ioctl)(fp, CDIOCPLAYMSF, + (caddr_t)&tmpb.msf, p); + goto out; case LINUX_CDROMPLAYBLK: error = copyin(SCARG(uap, data), &tmpl.blk, sizeof tmpl.blk); if (error) - return error; + goto out; tmpb.blk.blk = tmpl.blk.from; tmpb.blk.len = tmpl.blk.len; - return (*fp->f_ops->fo_ioctl)(fp, CDIOCPLAYBLOCKS, (caddr_t)&tmpb.blk, p); + error = (*fp->f_ops->fo_ioctl)(fp, CDIOCPLAYBLOCKS, + (caddr_t)&tmpb.blk, p); + goto out; case LINUX_CDROMVOLCTRL: error = copyin(SCARG(uap, data), &tmpl.vol, sizeof tmpl.vol); if (error) - return error; + goto out; tmpb.vol.vol[0] = tmpl.vol.channel0; tmpb.vol.vol[1] = tmpl.vol.channel1; tmpb.vol.vol[2] = tmpl.vol.channel2; tmpb.vol.vol[3] = tmpl.vol.channel3; - return (*fp->f_ops->fo_ioctl)(fp, CDIOCSETVOL, (caddr_t)&tmpb.vol, p); + error = (*fp->f_ops->fo_ioctl)(fp, CDIOCSETVOL, + (caddr_t)&tmpb.vol, p); + goto out; case LINUX_CDROMVOLREAD: - error = (*fp->f_ops->fo_ioctl)(fp, CDIOCGETVOL, (caddr_t)&tmpb.vol, p); + error = (*fp->f_ops->fo_ioctl)(fp, CDIOCGETVOL, + (caddr_t)&tmpb.vol, p); if (error) - return error; + goto out; tmpl.vol.channel0 = tmpb.vol.vol[0]; tmpl.vol.channel1 = tmpb.vol.vol[1]; tmpl.vol.channel2 = tmpb.vol.vol[2]; tmpl.vol.channel3 = tmpb.vol.vol[3]; - return copyout(&tmpl.vol, SCARG(uap, data), sizeof tmpl.vol); + error = copyout(&tmpl.vol, SCARG(uap, data), sizeof tmpl.vol); + goto out; case LINUX_CDROMPAUSE: SCARG(&ia, com) = CDIOCPAUSE; break; @@ -258,7 +273,7 @@ linux_ioctl_cdrom(p, v, retval) case LINUX_CDROMEJECT_SW: error = copyin(SCARG(uap, data), &arg, sizeof arg); if (error) - return error; + goto out; SCARG(&ia, com) = arg ? CDIOCALLOW : CDIOCPREVENT; break; case LINUX_CDROMEJECT: @@ -269,10 +284,15 @@ linux_ioctl_cdrom(p, v, retval) break; default: printf("linux_ioctl_cdrom: invalid ioctl %08lx\n", com); - return EINVAL; + error = EINVAL; + goto out; } SCARG(&ia, fd) = SCARG(uap, fd); SCARG(&ia, data) = SCARG(uap, data); - return sys_ioctl(p, &ia, retval); + error = sys_ioctl(p, &ia, retval); + +out: + FRELE(fp); + return (error); } diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index ba58a80a85c..12d9244a4c8 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_socket.c,v 1.21 2002/02/06 01:55:04 jasoni Exp $ */ +/* $OpenBSD: linux_socket.c,v 1.22 2002/02/13 20:43:42 jasoni Exp $ */ /* $NetBSD: linux_socket.c,v 1.14 1996/04/05 00:01:50 christos Exp $ */ /* @@ -993,7 +993,7 @@ linux_ioctl_socket(p, v, retval) void *v; register_t *retval; { - register struct linux_sys_ioctl_args /* { + struct linux_sys_ioctl_args /* { syscallarg(int) fd; syscallarg(u_long) com; syscallarg(caddr_t) data; @@ -1010,6 +1010,7 @@ linux_ioctl_socket(p, v, retval) fdp = p->p_fd; if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL) return (EBADF); + FREF(fp); if (fp->f_type == DTYPE_VNODE) { vp = (struct vnode *)fp->f_data; @@ -1113,16 +1114,18 @@ linux_ioctl_socket(p, v, retval) if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) && (sdl->sdl_family == AF_LINK) && (sdl->sdl_type == IFT_ETHER)) { - return copyout(LLADDR(sdl), + error = copyout(LLADDR(sdl), (caddr_t)&ifr->ifr_hwaddr.sa_data, LINUX_IFHWADDRLEN); + dosys = 0; + goto out; } } } - return ENOENT; + error = ENOENT; } default: - return EINVAL; + error = EINVAL; } out: @@ -1132,5 +1135,6 @@ out: error = sys_ioctl(p, &ia, retval); } + FRELE(fp); return (error); } diff --git a/sys/compat/linux/linux_termios.c b/sys/compat/linux/linux_termios.c index e010560fce7..a44ef13b0f7 100644 --- a/sys/compat/linux/linux_termios.c +++ b/sys/compat/linux/linux_termios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_termios.c,v 1.10 2001/10/26 12:03:27 art Exp $ */ +/* $OpenBSD: linux_termios.c,v 1.11 2002/02/13 20:43:42 jasoni Exp $ */ /* $NetBSD: linux_termios.c,v 1.3 1996/04/05 00:01:54 christos Exp $ */ /* @@ -83,8 +83,8 @@ static void bsd_termios_to_linux_termios __P((struct termios *, static void linux_termio_to_bsd_termios(lt, bts) - register struct linux_termio *lt; - register struct termios *bts; + struct linux_termio *lt; + struct termios *bts; { int index; @@ -166,8 +166,8 @@ linux_termio_to_bsd_termios(lt, bts) static void bsd_termios_to_linux_termio(bts, lt) - register struct termios *bts; - register struct linux_termio *lt; + struct termios *bts; + struct linux_termio *lt; { int i, mask; @@ -252,8 +252,8 @@ bsd_termios_to_linux_termio(bts, lt) static void linux_termios_to_bsd_termios(lts, bts) - register struct linux_termios *lts; - register struct termios *bts; + struct linux_termios *lts; + struct termios *bts; { int index; @@ -340,8 +340,8 @@ linux_termios_to_bsd_termios(lts, bts) static void bsd_termios_to_linux_termios(bts, lts) - register struct termios *bts; - register struct linux_termios *lts; + struct termios *bts; + struct linux_termios *lts; { int i, mask; @@ -439,17 +439,17 @@ bsd_termios_to_linux_termios(bts, lts) int linux_ioctl_termios(p, v, retval) - register struct proc *p; + struct proc *p; void *v; register_t *retval; { - register struct linux_sys_ioctl_args /* { + struct linux_sys_ioctl_args /* { syscallarg(int) fd; syscallarg(u_long) com; syscallarg(caddr_t) data; } */ *uap = v; - register struct file *fp; - register struct filedesc *fdp; + struct file *fp; + struct filedesc *fdp; u_long com; struct linux_termio tmplt; struct linux_termios tmplts; @@ -457,14 +457,17 @@ linux_ioctl_termios(p, v, retval) caddr_t sg; int idat; struct sys_ioctl_args ia; - int error; + int error = 0; 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; @@ -473,12 +476,10 @@ linux_ioctl_termios(p, v, retval) case LINUX_TCGETS: error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p); if (error) - return error; + goto out; bsd_termios_to_linux_termios(&tmpbts, &tmplts); error = copyout(&tmplts, SCARG(uap, data), sizeof tmplts); - if (error) - return error; - return 0; + goto out; case LINUX_TCSETS: case LINUX_TCSETSW: case LINUX_TCSETSF: @@ -488,10 +489,10 @@ linux_ioctl_termios(p, v, retval) */ error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p); if (error) - return error; + goto out; error = copyin(SCARG(uap, data), &tmplts, sizeof tmplts); if (error) - return error; + goto out; linux_termios_to_bsd_termios(&tmplts, &tmpbts); switch (com) { case LINUX_TCSETS: @@ -505,18 +506,14 @@ linux_ioctl_termios(p, v, retval) break; } error = (*fp->f_ops->fo_ioctl)(fp, com, (caddr_t)&tmpbts, p); - if (error) - return error; - return 0; + goto out; case LINUX_TCGETA: error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p); if (error) - return error; + goto out; bsd_termios_to_linux_termio(&tmpbts, &tmplt); error = copyout(&tmplt, SCARG(uap, data), sizeof tmplt); - if (error) - return error; - return 0; + goto out; case LINUX_TCSETA: case LINUX_TCSETAW: case LINUX_TCSETAF: @@ -526,10 +523,10 @@ linux_ioctl_termios(p, v, retval) */ error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p); if (error) - return error; + goto out; error = copyin(SCARG(uap, data), &tmplt, sizeof tmplt); if (error) - return error; + goto out; linux_termio_to_bsd_termios(&tmplt, &tmpbts); switch (com) { case LINUX_TCSETA: @@ -543,13 +540,11 @@ linux_ioctl_termios(p, v, retval) break; } error = (*fp->f_ops->fo_ioctl)(fp, com, (caddr_t)&tmpbts, p); - if (error) - return error; - return 0; + goto out; case LINUX_TIOCGETD: error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETD, (caddr_t)&idat, p); if (error) - return error; + goto out; switch (idat) { case TTYDISC: idat = LINUX_N_TTY; @@ -569,13 +564,11 @@ linux_ioctl_termios(p, v, retval) break; } error = copyout(&idat, SCARG(uap, data), sizeof idat); - if (error) - return error; - return 0; + goto out; case LINUX_TIOCSETD: error = copyin(SCARG(uap, data), &idat, sizeof idat); if (error) - return error; + goto out; switch (idat) { case LINUX_N_TTY: idat = TTYDISC; @@ -591,12 +584,11 @@ linux_ioctl_termios(p, v, retval) */ case LINUX_N_MOUSE: default: - return EINVAL; + error = EINVAL; + goto out; } error = (*fp->f_ops->fo_ioctl)(fp, TIOCSETD, (caddr_t)&idat, p); - if (error) - return error; - return 0; + goto out; case LINUX_TIOCGWINSZ: SCARG(&ia, com) = TIOCGWINSZ; break; @@ -664,34 +656,41 @@ linux_ioctl_termios(p, v, retval) error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p); if (error) - return error; + goto out; if ((int)SCARG(uap, data) == LINUX_TCIOFF) c = tmpbts.c_cc[VSTOP]; else c = tmpbts.c_cc[VSTART]; if (c == _POSIX_VDISABLE) - return 0; + goto out; sg = stackgap_init(p->p_emul); cp = (char *) stackgap_alloc(&sg, 1); if ((error = copyout(&c, cp, 1))) - return error; + goto out; SCARG(&wa, fd) = SCARG(uap, fd); SCARG(&wa, buf) = cp; SCARG(&wa, nbyte) = 1; - return sys_write(p, &wa, retval); + error = sys_write(p, &wa, retval); + goto out; } default: - return EINVAL; + error = EINVAL; + goto out; } SCARG(uap, data) = 0; break; default: - return EINVAL; + error = EINVAL; + goto out; } SCARG(&ia, fd) = SCARG(uap, fd); SCARG(&ia, data) = SCARG(uap, data); - return sys_ioctl(p, &ia, retval); + error = sys_ioctl(p, &ia, retval); + +out: + FRELE(fp); + return (error); } |