svn commit: r346625 - head/tests/sys/opencrypto
Enji Cooper
ngie at FreeBSD.org
Wed Apr 24 05:47:10 UTC 2019
Author: ngie
Date: Wed Apr 24 05:47:09 2019
New Revision: 346625
URL: https://svnweb.freebsd.org/changeset/base/346625
Log:
Don't leak `fd` when manipulating the device via `_getdev()`
Close the file descriptor when done calling ioctl with a try-finally block so
it doesn't get leaked.
MFC after: 2 months
Modified:
head/tests/sys/opencrypto/cryptodev.py
Modified: head/tests/sys/opencrypto/cryptodev.py
==============================================================================
--- head/tests/sys/opencrypto/cryptodev.py Wed Apr 24 05:24:10 2019 (r346624)
+++ head/tests/sys/opencrypto/cryptodev.py Wed Apr 24 05:47:09 2019 (r346625)
@@ -122,10 +122,12 @@ CIOCFINDDEV = 3223610220
CIOCCRYPTAEAD = 3225445229
def _getdev():
- fd = os.open('/dev/crypto', os.O_RDWR)
buf = array.array('I', [0])
- ioctl(fd, CRIOGET, buf, 1)
- os.close(fd)
+ fd = os.open('/dev/crypto', os.O_RDWR)
+ try:
+ ioctl(fd, CRIOGET, buf, 1)
+ finally:
+ os.close(fd)
return buf[0]
More information about the svn-src-head
mailing list