Fix memory leaks with async requests on firewire-core
Each request allocated a struct request_closure which was never freed. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
This commit is contained in:
parent
efb814334e
commit
caf94aaeab
13
src/fw.c
13
src/fw.c
|
@ -249,6 +249,7 @@ handle_device_event(raw1394handle_t handle,
|
||||||
struct device *device = (struct device *) ec;
|
struct device *device = (struct device *) ec;
|
||||||
struct address_closure *ac;
|
struct address_closure *ac;
|
||||||
struct request_closure *rc;
|
struct request_closure *rc;
|
||||||
|
unsigned long tag;
|
||||||
raw1394_errcode_t errcode;
|
raw1394_errcode_t errcode;
|
||||||
int len, phy_id;
|
int len, phy_id;
|
||||||
int i;
|
int i;
|
||||||
|
@ -287,8 +288,10 @@ handle_device_event(raw1394handle_t handle,
|
||||||
memcpy(rc->data, u->response.data, rc->length);
|
memcpy(rc->data, u->response.data, rc->length);
|
||||||
|
|
||||||
errcode = fw_to_raw1394_errcode(u->response.rcode);
|
errcode = fw_to_raw1394_errcode(u->response.rcode);
|
||||||
|
tag = rc->tag;
|
||||||
|
free(rc);
|
||||||
|
|
||||||
return fwhandle->tag_handler(handle, rc->tag, errcode);
|
return fwhandle->tag_handler(handle, tag, errcode);
|
||||||
|
|
||||||
case FW_CDEV_EVENT_REQUEST:
|
case FW_CDEV_EVENT_REQUEST:
|
||||||
ac = u64_to_ptr(u->request.closure);
|
ac = u64_to_ptr(u->request.closure);
|
||||||
|
@ -944,7 +947,7 @@ send_request(fw_handle_t handle, int tcode,
|
||||||
struct fw_cdev_send_request *request;
|
struct fw_cdev_send_request *request;
|
||||||
struct request_closure *closure;
|
struct request_closure *closure;
|
||||||
int ioctl_nr = FW_CDEV_IOC_SEND_REQUEST;
|
int ioctl_nr = FW_CDEV_IOC_SEND_REQUEST;
|
||||||
int fd, i;
|
int fd, i, retval;
|
||||||
|
|
||||||
#ifdef FW_CDEV_IOC_SEND_STREAM_PACKET /* added in kernel 2.6.30 */
|
#ifdef FW_CDEV_IOC_SEND_STREAM_PACKET /* added in kernel 2.6.30 */
|
||||||
if (tcode == TCODE_STREAM_DATA) {
|
if (tcode == TCODE_STREAM_DATA) {
|
||||||
|
@ -1024,7 +1027,11 @@ node_id_ok:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ioctl(fd, ioctl_nr, request);
|
retval = ioctl(fd, ioctl_nr, request);
|
||||||
|
if (retval < 0)
|
||||||
|
free(closure);
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Reference in New Issue