From patchwork Sun Mar 6 13:39:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 8513421 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D126CC0553 for ; Sun, 6 Mar 2016 13:39:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D86E201C0 for ; Sun, 6 Mar 2016 13:39:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2CA1201BC for ; Sun, 6 Mar 2016 13:39:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751431AbcCFNjy (ORCPT ); Sun, 6 Mar 2016 08:39:54 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:33374 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751454AbcCFNjv (ORCPT ); Sun, 6 Mar 2016 08:39:51 -0500 Received: from [179.179.52.194] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1acYuQ-00013o-OK; Sun, 06 Mar 2016 13:39:47 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.86) (envelope-from ) id 1acYu3-0002GW-RS; Sun, 06 Mar 2016 10:39:23 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Srinivas Kandagatla , Maxime Coquelin , Patrice Chotard , linux-arm-kernel@lists.infradead.org, kernel@stlinux.com Subject: [PATCH 4/6] [media] st-rc: prevent a endless loop Date: Sun, 6 Mar 2016 10:39:20 -0300 Message-Id: <087329695244e466f0c2d9a3a58e10ad399cd674.1457271549.git.mchehab@osg.samsung.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <076989c7736719982a1bc9557d7db072910d8efe.1457271549.git.mchehab@osg.samsung.com> References: <076989c7736719982a1bc9557d7db072910d8efe.1457271549.git.mchehab@osg.samsung.com> In-Reply-To: <076989c7736719982a1bc9557d7db072910d8efe.1457271549.git.mchehab@osg.samsung.com> References: <076989c7736719982a1bc9557d7db072910d8efe.1457271549.git.mchehab@osg.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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 As warned by smatch: drivers/media/rc/st_rc.c:110 st_rc_rx_interrupt() warn: this loop depends on readl() succeeding as readl() might fail, with likely means some unrecovered error, let's loop only if it succeeds. Signed-off-by: Mauro Carvalho Chehab Acked-by: Patrice Chotard --- drivers/media/rc/st_rc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c index 1fa0c9d1c508..151bfe2aea55 100644 --- a/drivers/media/rc/st_rc.c +++ b/drivers/media/rc/st_rc.c @@ -99,7 +99,7 @@ static irqreturn_t st_rc_rx_interrupt(int irq, void *data) unsigned int symbol, mark = 0; struct st_rc_device *dev = data; int last_symbol = 0; - u32 status; + int status; DEFINE_IR_RAW_EVENT(ev); if (dev->irq_wake) @@ -107,7 +107,7 @@ static irqreturn_t st_rc_rx_interrupt(int irq, void *data) status = readl(dev->rx_base + IRB_RX_STATUS); - while (status & (IRB_FIFO_NOT_EMPTY | IRB_OVERFLOW)) { + while (status > 0 && (status & (IRB_FIFO_NOT_EMPTY | IRB_OVERFLOW))) { u32 int_status = readl(dev->rx_base + IRB_RX_INT_STATUS); if (unlikely(int_status & IRB_RX_OVERRUN_INT)) { /* discard the entire collection in case of errors! */