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
This commit is contained in:
parent
8b82def341
commit
56bf253633
@ -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]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user