aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2009-10-07 18:39:56 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2009-10-14 15:55:19 -0400
commit7e44c0b56b07a5e34de9943cfb2fee72e71a9f0e (patch)
treeb7b30a9d709f439423bb13ed07868d61ae546258 /drivers/firewire
parenteaf76e0d027a917a013ad8a88a94132d0feab622 (diff)
firewire: cdev: fix memory leak in an error path
If copy_from_user in an FW_CDEV_IOC_SEND_RESPONSE ioctl failed, an inbound_transaction_resource instance is no longer referenced and needs to be freed. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/core-cdev.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index ced186d7e9a9..0516acd55ab9 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -698,6 +698,7 @@ static int ioctl_send_response(struct client *client, void *buffer)
698 struct fw_cdev_send_response *request = buffer; 698 struct fw_cdev_send_response *request = buffer;
699 struct client_resource *resource; 699 struct client_resource *resource;
700 struct inbound_transaction_resource *r; 700 struct inbound_transaction_resource *r;
701 int ret = 0;
701 702
702 if (release_client_resource(client, request->handle, 703 if (release_client_resource(client, request->handle,
703 release_request, &resource) < 0) 704 release_request, &resource) < 0)
@@ -707,13 +708,17 @@ static int ioctl_send_response(struct client *client, void *buffer)
707 resource); 708 resource);
708 if (request->length < r->length) 709 if (request->length < r->length)
709 r->length = request->length; 710 r->length = request->length;
710 if (copy_from_user(r->data, u64_to_uptr(request->data), r->length)) 711
711 return -EFAULT; 712 if (copy_from_user(r->data, u64_to_uptr(request->data), r->length)) {
713 ret = -EFAULT;
714 goto out;
715 }
712 716
713 fw_send_response(client->device->card, r->request, request->rcode); 717 fw_send_response(client->device->card, r->request, request->rcode);
718 out:
714 kfree(r); 719 kfree(r);
715 720
716 return 0; 721 return ret;
717} 722}
718 723
719static int ioctl_initiate_bus_reset(struct client *client, void *buffer) 724static int ioctl_initiate_bus_reset(struct client *client, void *buffer)