Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755905AbZJGWlK (ORCPT ); Wed, 7 Oct 2009 18:41:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755427AbZJGWlJ (ORCPT ); Wed, 7 Oct 2009 18:41:09 -0400 Received: from einhorn.in-berlin.de ([192.109.42.8]:44044 "EHLO einhorn.in-berlin.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755376AbZJGWlI (ORCPT ); Wed, 7 Oct 2009 18:41:08 -0400 X-Envelope-From: stefanr@s5r6.in-berlin.de Date: Thu, 8 Oct 2009 00:39:56 +0200 (CEST) From: Stefan Richter Subject: [PATCH 2/8] firewire: cdev: fix memory leak in an error path To: linux1394-devel@lists.sourceforge.net cc: linux-kernel@vger.kernel.org In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; CHARSET=us-ascii Content-Disposition: INLINE Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1686 Lines: 53 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 --- drivers/firewire/core-cdev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) Index: linux-2.6.31/drivers/firewire/core-cdev.c =================================================================== --- linux-2.6.31.orig/drivers/firewire/core-cdev.c +++ linux-2.6.31/drivers/firewire/core-cdev.c @@ -698,6 +698,7 @@ static int ioctl_send_response(struct cl struct fw_cdev_send_response *request = buffer; struct client_resource *resource; struct inbound_transaction_resource *r; + int ret = 0; if (release_client_resource(client, request->handle, release_request, &resource) < 0) @@ -707,13 +708,17 @@ static int ioctl_send_response(struct cl resource); if (request->length < r->length) r->length = request->length; - if (copy_from_user(r->data, u64_to_uptr(request->data), r->length)) - return -EFAULT; + + if (copy_from_user(r->data, u64_to_uptr(request->data), r->length)) { + ret = -EFAULT; + goto out; + } fw_send_response(client->device->card, r->request, request->rcode); + out: kfree(r); - return 0; + return ret; } static int ioctl_initiate_bus_reset(struct client *client, void *buffer) -- Stefan Richter -=====-==--= =-=- -=--- http://arcgraph.de/sr/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/