Skip to content

Commit

Permalink
firewire: fix memory leak of fw_request instances
Browse files Browse the repository at this point in the history
Found and debugged by Jay Fenlason <fenlason@redhat.com>.
The bug was especially noticeable with direct I/O over fw-sbp2.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
  • Loading branch information
Stefan Richter committed Jul 18, 2007
1 parent 5d59a6f commit 9c9bdf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/firewire/fw-transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,10 @@ fw_send_response(struct fw_card *card, struct fw_request *request, int rcode)
* check is sufficient to ensure we don't send response to
* broadcast packets or posted writes.
*/
if (request->ack != ACK_PENDING)
if (request->ack != ACK_PENDING) {
kfree(request);
return;
}

if (rcode == RCODE_COMPLETE)
fw_fill_response(&request->response, request->request_header,
Expand Down
4 changes: 4 additions & 0 deletions drivers/firewire/fw-transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ typedef void (*fw_transaction_callback_t)(struct fw_card *card, int rcode,
size_t length,
void *callback_data);

/*
* Important note: The callback must guarantee that either fw_send_response()
* or kfree() is called on the @request.
*/
typedef void (*fw_address_callback_t)(struct fw_card *card,
struct fw_request *request,
int tcode, int destination, int source,
Expand Down

0 comments on commit 9c9bdf4

Please sign in to comment.