From patchwork Mon May 16 22:07:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 789952 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4GM7agi000528 for ; Mon, 16 May 2011 22:07:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754826Ab1EPWH3 (ORCPT ); Mon, 16 May 2011 18:07:29 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:47995 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754660Ab1EPWH0 (ORCPT ); Mon, 16 May 2011 18:07:26 -0400 Received: by wya21 with SMTP id 21so3789964wya.19 for ; Mon, 16 May 2011 15:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:from:to:content-type:date:message-id :mime-version:x-mailer:content-transfer-encoding; bh=7VVZs9hMQH7Uwz5sAQ/QIscykyKAAXRa4ZHqSbroaaM=; b=AdYdGGfdhbzJ2YpzA2EE4axR2wH3tPxQHUn8KNAtc/6TTAi1WGnpaiP6YzT9TKmXRA mDTvpT0isTNRmwGLFr5bTUH2BtW/JQcq/GAk4ifFRXo3Qml97X2nnqsxfJAhR/S6RAOB svzjbcYO6zvMUxTEQlmKD042NObOkR8vMR8uc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; b=jln+UXJ0WZAmt6qQvTf+aeCZ1KEGegAlstFT52V5f4zPfNryQo/jSCMUure/25oXwE BbGxifyzuG+WbD4J/oPBSiZEZq+6rULSHu8ejiZUnTt2COeXXsiiTbdFA7rqaL7ZlMCH I/O2jiEhCLbc2pTQ1Bzrd2okTkLPB9s1PvX/8= Received: by 10.227.204.71 with SMTP id fl7mr1126079wbb.17.1305583644696; Mon, 16 May 2011 15:07:24 -0700 (PDT) Received: from [10.64.64.65] (92.41.251.198.threembb.co.uk [92.41.251.198]) by mx.google.com with ESMTPS id y29sm3417980wbd.4.2011.05.16.15.07.22 (version=SSLv3 cipher=OTHER); Mon, 16 May 2011 15:07:23 -0700 (PDT) Subject: [PATCH ] dvb-usb provide exit for any structure inside priv. From: Malcolm Priestley To: linux-media@vger.kernel.org Date: Mon, 16 May 2011 23:07:17 +0100 Message-ID: <1305583637.2481.3.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 16 May 2011 22:07:39 +0000 (UTC) Currently priv is freed from memory by dvb-usb on any error or exit. If any buffer has been allocated in the priv structure, freeing it is tricky. While freeing it on device disconnect is fairly easy, on error it is almost impossible because it has been removed from memory by dvb-usb. This patch provides an exit from the priv. Signed-off-by: Malcolm Priestley --- drivers/media/dvb/dvb-usb/dvb-usb-init.c | 2 ++ drivers/media/dvb/dvb-usb/dvb-usb.h | 1 + 2 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index 2e3ea0f..217b948 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c @@ -118,6 +118,8 @@ static int dvb_usb_exit(struct dvb_usb_device *d) dvb_usb_i2c_exit(d); deb_info("state should be zero now: %x\n", d->state); d->state = DVB_USB_STATE_INIT; + if (d->props.priv_exit) + d->props.priv_exit(d); kfree(d->priv); kfree(d); return 0; diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index 76a8096..044c906 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h @@ -263,6 +263,7 @@ struct dvb_usb_device_properties { int no_reconnect; int size_of_priv; + int (*priv_exit) (struct dvb_usb_device *); int num_adapters; struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];