From patchwork Tue Jan 14 16:57:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 3487831 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D0BDEC02DC for ; Tue, 14 Jan 2014 20:00:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D7AD020225 for ; Tue, 14 Jan 2014 20:00:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E14692021E for ; Tue, 14 Jan 2014 20:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751503AbaANUAp (ORCPT ); Tue, 14 Jan 2014 15:00:45 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:56778 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751472AbaANUAo (ORCPT ); Tue, 14 Jan 2014 15:00:44 -0500 Received: from [177.143.150.208] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1W3AAD-0002af-M4; Tue, 14 Jan 2014 20:00:42 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1W37IW-0003nQ-IR; Tue, 14 Jan 2014 14:57:04 -0200 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH] em28xx-alsa: Fix error patch for init/fini Date: Tue, 14 Jan 2014 14:57:03 -0200 Message-Id: <1389718623-14558-1-git-send-email-m.chehab@samsung.com> X-Mailer: git-send-email 1.8.3.1 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If something bad happens during init, we free the card data. However, we still keep it initialized, causing some dependent code to be called at .fini. Fix it. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx-audio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c index 1563f71a5ea2..45bea1adc11c 100644 --- a/drivers/media/usb/em28xx/em28xx-audio.c +++ b/drivers/media/usb/em28xx/em28xx-audio.c @@ -948,6 +948,7 @@ urb_free: card_free: snd_card_free(card); + adev->sndcard = NULL; return err; } @@ -966,12 +967,12 @@ static int em28xx_audio_fini(struct em28xx *dev) em28xx_info("Closing audio extension"); - snd_card_disconnect(dev->adev.sndcard); - flush_work(&dev->wq_trigger); + if (dev->adev.sndcard) { + snd_card_disconnect(dev->adev.sndcard); + flush_work(&dev->wq_trigger); - em28xx_audio_free_urb(dev); + em28xx_audio_free_urb(dev); - if (dev->adev.sndcard) { snd_card_free(dev->adev.sndcard); dev->adev.sndcard = NULL; }