diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2003-10-19 20:41:07 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2003-10-19 20:41:07 +0000 |
commit | be405a4cbded7cdf17be85da15ed406cd32d25cf (patch) | |
tree | 005101ab125d7c43f5a5366aaad1dafbe9eb3c26 /sys/opencrypto | |
parent | 676085d67110550e1f32ca4a1a3b4b1faf055dc5 (diff) | |
download | FreeBSD-src-be405a4cbded7cdf17be85da15ed406cd32d25cf.zip FreeBSD-src-be405a4cbded7cdf17be85da15ed406cd32d25cf.tar.gz |
falloc allocates a file structure and adds it to the file descriptor
table, acquiring the necessary locks as it works. It usually returns
two references to the new descriptor: one in the descriptor table
and one via a pointer argument.
As falloc releases the FILEDESC lock before returning, there is a
potential for a process to close the reference in the file descriptor
table before falloc's caller gets to use the file. I don't think this
can happen in practice at the moment, because Giant indirectly protects
closes.
To stop the file being completly closed in this situation, this change
makes falloc set the refcount to two when both references are returned.
This makes life easier for several of falloc's callers, because the
first thing they previously did was grab an extra reference on the
file.
Reviewed by: iedowse
Idea run past: jhb
Diffstat (limited to 'sys/opencrypto')
-rw-r--r-- | sys/opencrypto/cryptodev.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index e3bbba5..51617f5 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -751,7 +751,7 @@ cryptoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) FREE(fcr, M_XDATA); return (error); } - fhold(f); + /* falloc automatically provides an extra reference to 'f'. */ f->f_flag = FREAD | FWRITE; f->f_type = DTYPE_CRYPTO; f->f_ops = &cryptofops; |