From patchwork Thu Aug 18 23:45:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Rankin X-Patchwork-Id: 264 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Thu, 18 Aug 2011 23:45:37 +0000 Received: from casper.infradead.org [85.118.1.10] by gaivota with IMAP (fetchmail-6.3.20) for (single-drop); Thu, 18 Aug 2011 17:58:01 -0700 (PDT) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QuCHI-0002Gv-NZ; Thu, 18 Aug 2011 23:45:37 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751975Ab1HRXpd (ORCPT + 1 other); Thu, 18 Aug 2011 19:45:33 -0400 Received: from nm2.bt.bullet.mail.ird.yahoo.com ([212.82.108.233]:24262 "HELO nm2.bt.bullet.mail.ird.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751399Ab1HRXpd (ORCPT ); Thu, 18 Aug 2011 19:45:33 -0400 Received: from [212.82.108.229] by nm2.bt.bullet.mail.ird.yahoo.com with NNFMP; 18 Aug 2011 23:45:31 -0000 Received: from [212.82.108.224] by tm2.bt.bullet.mail.ird.yahoo.com with NNFMP; 18 Aug 2011 23:45:31 -0000 Received: from [127.0.0.1] by omp1001.bt.mail.ird.yahoo.com with NNFMP; 18 Aug 2011 23:45:31 -0000 X-Yahoo-Newman-Id: 568855.93882.bm@omp1001.bt.mail.ird.yahoo.com Received: (qmail 13791 invoked from network); 18 Aug 2011 23:45:31 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type; b=CbC+2t8mnQMk8+cB+Qai8nb+LS7K7IACxl6H/Yv/AqxPiD/IAsI6KnEzuOB2GIYf1E6RjxmjkVNG5gMpFXE1KyKSIdlmu7seNu0Ma/7Ml97GtnSvCg0Fa4D5Sc0HVfMdV3e2DO31dFZN3UXjJFQ0daHOr0MPwCswyIQR9VEJtXc= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1313711131; bh=Bq0nJhnsEfRsuFXpPapSrWvIBr3gP4pjhKHwOOw8IUg=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type; b=WhKggNQf88179RIOmwzz1sncWDDbk+Y5OsVmo2KzmIOvFBhhCDw5gPViniHoQUYw44VslJSq5xfMxaUUlUbaRndEqNoAWTcTI66ZV6cd4gkLbofKfwHn6DGqaGSmOtRYjhhwTXgq0QMJFHvlfUIyAKsOlLoTUuVwMDssbU/Cgb0= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: c5vrt7AVM1kq_Hr0VCjqe5uNvhevIXSaAdZ_0YVRLnbQAdX wVB4vgcbwifH2vhkYmlStl48EeClfhu9VHi250f.fBr8AMc18nbe8q4n_u2m 0K6I6bJmNtpbAQE.rG.7WoOvUB8JZYL0IYLJB47mcV2Qvcn2_FfyxYbSx_Nf Jdvb2zk7wJhgdB0OYLid.NqvOtqZwEuGqgj3Ny9YrqU8UT3gm6sS65SQgfJl 4ErF6G5zApD6XZhnLNuChoWgoAIOPdK0VlMO5uB32LNJq8PChAsYRMvMK.T7 X0.otx5J5aKnhw4IoQ5rV0K1.mm5Bfcu26LckYW.KMCTXMSR2QVsKPjN0eBS JMcCkDrmVwMCHsIL4nZjT3Im2rJ5Rdzoguk5XusfQjAoQZceV.17GJMmZqqK KUTA- X-Yahoo-SMTP: dMK34oyswBBlfKesWTI5ovDjFOUFE6shtILt.ZXnUEjQHhWq Received: from wellhouse.underworld (rankincj@86.183.125.64 with login) by smtp817.mail.ird.yahoo.com with SMTP; 18 Aug 2011 23:45:30 +0000 GMT Received: from volcano.underworld (volcano.underworld [192.168.0.3]) by wellhouse.underworld (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p7INjRaN007892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 19 Aug 2011 00:45:29 +0100 Message-ID: <4E4DA417.6030809@yahoo.com> Date: Fri, 19 Aug 2011 00:45:27 +0100 From: Chris Rankin User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110707 Thunderbird/5.0 MIME-Version: 1.0 To: Devin Heitmueller CC: linux-media@vger.kernel.org, mchehab@redhat.com, Antti Palosaari Subject: Re: [PATCH] Latest version of em28xx / em28xx-dvb patch for PCTV 290e References: <4E4D5157.2080406@yahoo.com> In-Reply-To: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch closes the race on the device and extension lists at USB disconnect time. Previously, the device was removed from the device list during em28xx_release_resources(), and then passed to the em28xx_close_extension() function so that all extensions could run their fini() operations. However, this left a (brief, theoretical, highly unlikely ;-)) window between these two calls during which a new module could call em28xx_register_extension(). The result would have been that the em28xx_usb_disconnect() function would also have passed the device to the new extension's fini() function, despite never having called the extension's init() function. This patch also restores em28xx_close_extension()'s symmetry with em28xx_init_extension(), and establishes the property that every device in the device list must have been initialised for every extension in the extension list. Signed-of-by: Chris Rankin --- linux-3.0/drivers/media/video/em28xx/em28xx-cards.c.orig 2011-08-19 00:23:17.000000000 +0100 +++ linux-3.0/drivers/media/video/em28xx/em28xx-cards.c 2011-08-19 00:32:40.000000000 +0100 @@ -2738,9 +2738,9 @@ #endif /* CONFIG_MODULES */ /* - * em28xx_realease_resources() + * em28xx_release_resources() * unregisters the v4l2,i2c and usb devices - * called when the device gets disconected or at module unload + * called when the device gets disconnected or at module unload */ void em28xx_release_resources(struct em28xx *dev) { @@ -2754,8 +2754,6 @@ em28xx_release_analog_resources(dev); - em28xx_remove_from_devlist(dev); - em28xx_i2c_unregister(dev); v4l2_device_unregister(&dev->v4l2_dev); @@ -3152,7 +3150,7 @@ /* * em28xx_usb_disconnect() - * called when the device gets diconencted + * called when the device gets disconnected * video device will be unregistered on v4l2_close in case it is still open */ static void em28xx_usb_disconnect(struct usb_interface *interface) --- linux-3.0/drivers/media/video/em28xx/em28xx-core.c.orig 2011-08-18 23:07:51.000000000 +0100 +++ linux-3.0/drivers/media/video/em28xx/em28xx-core.c 2011-08-19 00:27:00.000000000 +0100 @@ -1160,18 +1160,6 @@ static DEFINE_MUTEX(em28xx_devlist_mutex); /* - * em28xx_realease_resources() - * unregisters the v4l2,i2c and usb devices - * called when the device gets disconected or at module unload -*/ -void em28xx_remove_from_devlist(struct em28xx *dev) -{ - mutex_lock(&em28xx_devlist_mutex); - list_del(&dev->devlist); - mutex_unlock(&em28xx_devlist_mutex); -}; - -/* * Extension interface */ @@ -1221,14 +1209,13 @@ void em28xx_close_extension(struct em28xx *dev) { - struct em28xx_ops *ops = NULL; + const struct em28xx_ops *ops = NULL; mutex_lock(&em28xx_devlist_mutex); - if (!list_empty(&em28xx_extension_devlist)) { - list_for_each_entry(ops, &em28xx_extension_devlist, next) { - if (ops->fini) - ops->fini(dev); - } + list_for_each_entry(ops, &em28xx_extension_devlist, next) { + if (ops->fini) + ops->fini(dev); } + list_del(&dev->devlist); mutex_unlock(&em28xx_devlist_mutex); }