public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
* [PATCH 4/6] [media] st-rc: prevent a endless loop
       [not found] <076989c7736719982a1bc9557d7db072910d8efe.1457271549.git.mchehab@osg.samsung.com>
@ 2016-03-06 13:39 ` Mauro Carvalho Chehab
  2016-03-07  8:16   ` Patrice Chotard
  0 siblings, 1 reply; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2016-03-06 13:39 UTC (permalink / raw)
  To: linux-arm-kernel

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 <mchehab@osg•samsung.com>
---
 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!  */
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 4/6] [media] st-rc: prevent a endless loop
  2016-03-06 13:39 ` [PATCH 4/6] [media] st-rc: prevent a endless loop Mauro Carvalho Chehab
@ 2016-03-07  8:16   ` Patrice Chotard
  0 siblings, 0 replies; 2+ messages in thread
From: Patrice Chotard @ 2016-03-07  8:16 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mauro

On 03/06/2016 02:39 PM, Mauro Carvalho Chehab wrote:
> 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 <mchehab@osg•samsung.com>
> ---
>   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!  */

Acked-by: Patrice Chotard <patrice.chotard@st•com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-07  8:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <076989c7736719982a1bc9557d7db072910d8efe.1457271549.git.mchehab@osg.samsung.com>
2016-03-06 13:39 ` [PATCH 4/6] [media] st-rc: prevent a endless loop Mauro Carvalho Chehab
2016-03-07  8:16   ` Patrice Chotard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox