From patchwork Sun Aug 10 02:14:20 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: 4703831 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 5EDEBC033A for ; Sun, 10 Aug 2014 02:14:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71E4C20160 for ; Sun, 10 Aug 2014 02:14:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8852D20158 for ; Sun, 10 Aug 2014 02:14:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751774AbaHJCOf (ORCPT ); Sat, 9 Aug 2014 22:14:35 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:56216 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751631AbaHJCOd (ORCPT ); Sat, 9 Aug 2014 22:14:33 -0400 Received: from [187.57.189.12] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1XGIeS-0008LS-Va; Sun, 10 Aug 2014 02:14:29 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1XGIeO-00054f-08; Sat, 09 Aug 2014 23:14:24 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH 1/3] au0828: fix checks if dvb is initialized Date: Sat, 9 Aug 2014 23:14:20 -0300 Message-Id: <1407636862-19394-2-git-send-email-m.chehab@samsung.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1407636862-19394-1-git-send-email-m.chehab@samsung.com> References: <1407636862-19394-1-git-send-email-m.chehab@samsung.com> 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.6 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 dev->dvb is always not null, as it is an area at the dev memory. So, checking if (dev->dvb) is always true. Instead of this stupid check, what the code wants to do is to know if the DVB was successully registered. Fix it by checking, instead, for dvb->frontend. It should also be sure that this var will be NULL if the device was not properly initialized. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-dvb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c index ee45990c0be1..bc4ea5397e92 100644 --- a/drivers/media/usb/au0828/au0828-dvb.c +++ b/drivers/media/usb/au0828/au0828-dvb.c @@ -267,7 +267,7 @@ static int au0828_dvb_start_feed(struct dvb_demux_feed *feed) if (!demux->dmx.frontend) return -EINVAL; - if (dvb) { + if (dvb->frontend) { mutex_lock(&dvb->lock); dvb->start_count++; dprintk(1, "%s(), start_count: %d, stop_count: %d\n", __func__, @@ -296,7 +296,7 @@ static int au0828_dvb_stop_feed(struct dvb_demux_feed *feed) dprintk(1, "%s()\n", __func__); - if (dvb) { + if (dvb->frontend) { cancel_work_sync(&dev->restart_streaming); mutex_lock(&dvb->lock); @@ -526,8 +526,7 @@ void au0828_dvb_unregister(struct au0828_dev *dev) for (i = 0; i < URB_COUNT; i++) kfree(dev->dig_transfer_buffer[i]); } - - + dvb->frontend = NULL; } /* All the DVB attach calls go here, this function get's modified @@ -608,6 +607,7 @@ int au0828_dvb_register(struct au0828_dev *dev) if (ret < 0) { if (dvb->frontend->ops.release) dvb->frontend->ops.release(dvb->frontend); + dvb->frontend = NULL; return ret; } @@ -618,7 +618,7 @@ void au0828_dvb_suspend(struct au0828_dev *dev) { struct au0828_dvb *dvb = &dev->dvb; - if (dvb && dev->urb_streaming) { + if (dvb->frontend && dev->urb_streaming) { pr_info("stopping DVB\n"); cancel_work_sync(&dev->restart_streaming); @@ -635,7 +635,7 @@ void au0828_dvb_resume(struct au0828_dev *dev) { struct au0828_dvb *dvb = &dev->dvb; - if (dvb && dev->urb_streaming) { + if (dvb->frontend && dev->urb_streaming) { pr_info("resuming DVB\n"); au0828_set_frontend(dvb->frontend);