Date: Tue, 03 Sep 2019 14:07:46 -0000 From: Enji Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346625 - head/tests/sys/opencrypto Message-ID: <201904240547.x3O5l9jn098748@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904240547.x3O5l9jn098748>