diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2017-07-09 14:57:41 +0200 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2017-07-09 14:57:41 +0200 |
commit | ccec7a182f1373fb15051a1c03d28e44c4188cce (patch) | |
tree | 74410248233fe50cf469f1781a0c10c5a778fca9 | |
parent | 31569c169a94640759a28acd420f27e0f39d9d3f (diff) | |
download | 0xFFFF-ccec7a182f1373fb15051a1c03d28e44c4188cce.tar.bz2 |
disk: Close device file handle when freeing structures
-rw-r--r-- | src/disk.c | 7 | ||||
-rw-r--r-- | src/disk.h | 1 | ||||
-rw-r--r-- | src/operations.c | 5 |
3 files changed, 12 insertions, 1 deletions
@@ -413,6 +413,13 @@ int disk_init(struct usb_device_info * dev) { } +void disk_exit(struct usb_device_info * dev) { + + if ( dev->data >= 0 ) + close(dev->data); + +} + enum device disk_get_device(struct usb_device_info * dev) { return dev->device; @@ -24,6 +24,7 @@ #include "usb-device.h" int disk_init(struct usb_device_info * dev); +void disk_exit(struct usb_device_info * dev); enum device disk_get_device(struct usb_device_info * dev); diff --git a/src/operations.c b/src/operations.c index cd7ef44..b3be2c7 100644 --- a/src/operations.c +++ b/src/operations.c @@ -91,8 +91,11 @@ clean: void dev_free(struct device_info * dev) { - if ( dev->usb ) + if ( dev->usb ) { + if ( dev->usb->flash_device->protocol == FLASH_DISK ) + disk_exit(dev->usb); usb_close_device(dev->usb); + } free(dev); } |