From patchwork Tue Mar 12 15:09:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Volokh Konstantin X-Patchwork-Id: 2256831 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B3A6A4006E for ; Tue, 12 Mar 2013 15:17:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755040Ab3CLPRD (ORCPT ); Tue, 12 Mar 2013 11:17:03 -0400 Received: from mail-la0-f44.google.com ([209.85.215.44]:58165 "EHLO mail-la0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754038Ab3CLPRC (ORCPT ); Tue, 12 Mar 2013 11:17:02 -0400 Received: by mail-la0-f44.google.com with SMTP id eb20so5363470lab.31 for ; Tue, 12 Mar 2013 08:17:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=DJx0fPw+Qyy719DF8XEsq1NPXCDmEbj5xSZCATqV1Lw=; b=jHEdvP8QOxx4KHsFlqg1gHQ6tz78MW2J3b+Ya+mkwpaIQUhIZBRHzv9JkjgeG1D669 TEFiWieMmfSsHy56mgiDFy3Xwl5Xu2fz4x7va0VLNIdi+wuwqNSnH9vx2gdaIbLAaT8Y 10PMEZRkDOLhTkTW1Od7knHa+rmLrbIqm9n5nZDuQ7bpWUTTvDviuAIZkL+QM+CFaB3/ T6lNuc4Y0HX2EVtsztU8LrB+4HJOmzhmGAL/1Jm2BgFACxxWaXSInA1/7bWxi6LbhcJd TGdVqM3wXn7543x/CODO+uHZ99MubnJBSJye3WQjfWcB+uqK1yJAYylm5PSood7+hQtb 3gOg== X-Received: by 10.112.8.231 with SMTP id u7mr6120392lba.45.1363101420568; Tue, 12 Mar 2013 08:17:00 -0700 (PDT) Received: from Volokh.Home (host-60-159-66-217.spbmts.ru. [217.66.159.60]) by mx.google.com with ESMTPS id fz16sm9439703lab.5.2013.03.12.08.16.49 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 12 Mar 2013 08:16:59 -0700 (PDT) From: Volokh Konstantin To: hverkuil@xs4all.nl, linux-media@vger.kernel.org Cc: Volokh Konstantin Subject: [PATCH 2/2] hverkuil/go7007: staging: media: go7007: rmmod firmware protection stuff Date: Tue, 12 Mar 2013 19:09:30 +0400 Message-Id: <1363100970-11080-2-git-send-email-volokh84@gmail.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1363100970-11080-1-git-send-email-volokh84@gmail.com> References: <1363100970-11080-1-git-send-email-volokh84@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If firmware wasn`t load, rmmod fail with oops: usbcore: deregistering interface driver go7007 BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] __mutex_lock_slowpath+0xa2/0x140 PGD 13143b067 PUD 132a52067 PMD 0 Oops: 0002 [#1] SMP Modules linked in: go7007_usb(C-) go7007(C) videobuf2_core bttv videobuf_dma_sg videobuf_core btcx_risc rc_core v4l2_common videodev videobuf2_vmalloc videobuf2_memops tveeprom CPU 0 Pid: 3305, comm: rmmod Tainted: G C 3.9.0-rc1+ #4 To Be Filled By O.E.M. To Be Filled By O.E.M./H55MX-S Series RIP: 0010:[] [] __mutex_lock_slowpath+0xa2/0x140 RSP: 0018:ffff88013220bd18 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff880132264c80 RCX: 00000000ffffffff RDX: ffff88013220bd20 RSI: ffff880130d3ecc0 RDI: ffff880132264c84 RBP: ffff88013220bd68 R08: 0000000000000000 R09: ffffea0004c5c940 R10: ffffffff811a08d3 R11: 0000000000027854 R12: ffff880132264c84 R13: ffff8801325ec410 R14: 00000000ffffffff R15: ffff880132264c88 Mar 12 01:25:57 Video kernel: [ 128.939419] FS: 00007fb32649d700(0000) GS:ffff880137c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 0000000000000000 CR3: 0000000130f1d000 CR4: 00000000000007f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process rmmod (pid: 3305, threadinfo ffff88013220a000, task ffff8801325ec410) Stack: ffff88013220bd48 ffff880132264c88 0000000000000000 ffff880131abf800 ffff880130d3ecc0 ffff880132264c80 ffff880132264c80 ffff880132264478 ffff880132264000 0000000000000000 ffff88013220bd88 ffffffff81797c05 Call Trace: [] mutex_lock+0x25/0x40 [] go7007_usb_disconnect+0x41/0xb0 [go7007_usb] [] usb_unbind_interface+0x5b/0x130 [] __device_release_driver+0x61/0xd0 [] driver_detach+0xb0/0xc0 [] bus_remove_driver+0x79/0xd0 [] driver_unregister+0x5a/0x90 [] usb_deregister+0x64/0xd0 [] go7007_usb_driver_exit+0x10/0x12 [go7007_usb] [] sys_delete_module+0x15c/0x240 [] system_call_fastpath+0x16/0x1b Code: 00 4c 8d 63 04 4c 8d 7b 08 41 be ff ff ff ff 4c 89 e7 e8 92 26 00 00 48 8b 43 10 48 8d 55 b8 4c 89 7d b8 48 89 53 10 48 89 45 c0 <48> 89 10 44 89 f0 4c 89 6d c8 87 03 83 f8 01 75 1f eb 27 0f 1f RIP [] __mutex_lock_slowpath+0xa2/0x140 RSP CR2: 0000000000000000 Signed-off-by: Volokh Konstantin --- drivers/staging/media/go7007/go7007-usb.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/media/go7007/go7007-usb.c b/drivers/staging/media/go7007/go7007-usb.c index bd23d7d..48ad01f 100644 --- a/drivers/staging/media/go7007/go7007-usb.c +++ b/drivers/staging/media/go7007/go7007-usb.c @@ -1316,18 +1316,19 @@ static void go7007_usb_disconnect(struct usb_interface *intf) { struct go7007 *go = to_go7007(usb_get_intfdata(intf)); - mutex_lock(&go->queue_lock); - mutex_lock(&go->serialize_lock); - - if (go->audio_enabled) - go7007_snd_remove(go); - - go->status = STATUS_SHUTDOWN; - v4l2_device_disconnect(&go->v4l2_dev); - video_unregister_device(&go->vdev); - mutex_unlock(&go->serialize_lock); - mutex_unlock(&go->queue_lock); - + if (go->status == STATUS_ONLINE) { + mutex_lock(&go->queue_lock); + mutex_lock(&go->serialize_lock); + + if (go->audio_enabled) + go7007_snd_remove(go); + + go->status = STATUS_SHUTDOWN; + v4l2_device_disconnect(&go->v4l2_dev); + video_unregister_device(&go->vdev); + mutex_unlock(&go->serialize_lock); + mutex_unlock(&go->queue_lock); + } v4l2_device_put(&go->v4l2_dev); }