[2.6.22.2 review 48/84] firewire: fix memory leak of fw_requestinstances

From: Greg KH
Date: Tue Aug 07 2007 - 17:11:46 EST


From: Stefan Richter <stefanr@xxxxxxxxxxxxxxxxx>

Found and debugged by Jay Fenlason <fenlason@xxxxxxxxxx>.
The bug was especially noticeable with direct I/O over fw-sbp2.

Same as commit 9c9bdf4d50730fd04b06077e22d7a83b585f26b5.

Signed-off-by: Stefan Richter <stefanr@xxxxxxxxxxxxxxxxx>
Signed-off-by: Kristian Høgsberg <krh@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
drivers/firewire/fw-transaction.c | 4 +++-
drivers/firewire/fw-transaction.h | 4 ++++
2 files changed, 7 insertions(+), 1 deletion(-)

--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -605,8 +605,10 @@ fw_send_response(struct fw_card *card, s
* 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,
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -124,6 +124,10 @@ typedef void (*fw_transaction_callback_t
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,

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/