From patchwork Mon Mar 25 12:55:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 2331041 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 19E313FD8C for ; Mon, 25 Mar 2013 12:56:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757622Ab3CYM4J (ORCPT ); Mon, 25 Mar 2013 08:56:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30107 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757598Ab3CYM4G (ORCPT ); Mon, 25 Mar 2013 08:56:06 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2PCu5ba009049 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 25 Mar 2013 08:56:05 -0400 Received: from pedra (vpn1-6-62.gru2.redhat.com [10.97.6.62]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2PCu3aM024918 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 25 Mar 2013 08:56:05 -0400 Received: from v4l by pedra with local (Exim 4.80.1) (envelope-from ) id 1UK6wV-0004gu-76; Mon, 25 Mar 2013 09:56:03 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List Subject: [PATCH 3/3] tuner-core: handle errors when getting signal strength/afc Date: Mon, 25 Mar 2013 09:55:59 -0300 Message-Id: <1364216159-12707-4-git-send-email-mchehab@redhat.com> In-Reply-To: <1364216159-12707-1-git-send-email-mchehab@redhat.com> References: <201303251232.31456.hverkuil@xs4all.nl> <1364216159-12707-1-git-send-email-mchehab@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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 If those callbacks fail, it should return zero, and not a random value. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/tuner-core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c index f1e8b40..cf9a9af 100644 --- a/drivers/media/v4l2-core/tuner-core.c +++ b/drivers/media/v4l2-core/tuner-core.c @@ -220,18 +220,20 @@ static void fe_standby(struct dvb_frontend *fe) static int fe_has_signal(struct dvb_frontend *fe) { - u16 strength = 0; + u16 strength; - fe->ops.tuner_ops.get_rf_strength(fe, &strength); + if (fe->ops.tuner_ops.get_rf_strength(fe, &strength) < 0) + return 0; return strength; } static int fe_get_afc(struct dvb_frontend *fe) { - s32 afc = 0; + s32 afc; - fe->ops.tuner_ops.get_afc(fe, &afc); + if (fe->ops.tuner_ops.get_afc(fe, &afc) < 0) + return 0; return afc; }