Commit 7e44c0b56b07a5e34de9943cfb2fee72e71a9f0e

Authored by Stefan Richter
1 parent eaf76e0d02

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>

Showing 1 changed file with 8 additions and 3 deletions Side-by-side Diff

drivers/firewire/core-cdev.c
... ... @@ -698,6 +698,7 @@
698 698 struct fw_cdev_send_response *request = buffer;
699 699 struct client_resource *resource;
700 700 struct inbound_transaction_resource *r;
  701 + int ret = 0;
701 702  
702 703 if (release_client_resource(client, request->handle,
703 704 release_request, &resource) < 0)
704 705  
705 706  
706 707  
... ... @@ -707,13 +708,17 @@
707 708 resource);
708 709 if (request->length < r->length)
709 710 r->length = request->length;
710   - if (copy_from_user(r->data, u64_to_uptr(request->data), r->length))
711   - return -EFAULT;
712 711  
  712 + if (copy_from_user(r->data, u64_to_uptr(request->data), r->length)) {
  713 + ret = -EFAULT;
  714 + goto out;
  715 + }
  716 +
713 717 fw_send_response(client->device->card, r->request, request->rcode);
  718 + out:
714 719 kfree(r);
715 720  
716   - return 0;
  721 + return ret;
717 722 }
718 723  
719 724 static int ioctl_initiate_bus_reset(struct client *client, void *buffer)