Patchwork [1/7] drivers/ide/ide-cs.c: adjust suspicious bit operation

login
register
mail settings
Submitter Julia Lawall
Date June 8, 2012, 5:14 a.m.
Message ID <alpine.DEB.2.02.1206080712510.1793@hadrien>
Download mbox | patch
Permalink /patch/163713/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Julia Lawall - June 8, 2012, 5:14 a.m.
From nobody Wed Jun  6 21:48:37 CEST 2012
From: Julia Lawall <Julia.Lawall@lip6.fr>
To: "David S. Miller" <davem@davemloft.net>
Cc: linux-ide@vger.kernel.org,linux-kernel@vger.kernel.org,joe@perches.com
Subject: [PATCH 1/7] drivers/ide/ide-cs.c: adjust suspicious bit operation

From: Julia Lawall <Julia.Lawall@lip6.fr>

IO_DATA_PATH_WIDTH_8 is 0, so a bit-and with it is always false.  The
value IO_DATA_PATH_WIDTH covers the bits of the IO_DATA_PATH constants, so
first pick those bits and then make the test using !=.

This problem was found using Coccinelle (http://coccinelle.lip6.fr/).

Signed-off-by: Julia Lawall <julia@diku.dk>

---
  drivers/ide/ide-cs.c |    3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
walter harms - June 8, 2012, 7:30 a.m.
Am 08.06.2012 07:14, schrieb Julia Lawall:
>> From nobody Wed Jun  6 21:48:37 CEST 2012
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> To: "David S. Miller" <davem@davemloft.net>
> Cc: linux-ide@vger.kernel.org,linux-kernel@vger.kernel.org,joe@perches.com
> Subject: [PATCH 1/7] drivers/ide/ide-cs.c: adjust suspicious bit operation
> 
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> IO_DATA_PATH_WIDTH_8 is 0, so a bit-and with it is always false.  The
> value IO_DATA_PATH_WIDTH covers the bits of the IO_DATA_PATH constants, so
> first pick those bits and then make the test using !=.
> 
> This problem was found using Coccinelle (http://coccinelle.lip6.fr/).
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---
>  drivers/ide/ide-cs.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
> index 28e344e..f1e922e 100644
> --- a/drivers/ide/ide-cs.c
> +++ b/drivers/ide/ide-cs.c
> @@ -167,7 +167,8 @@ static int pcmcia_check_one_config(struct
> pcmcia_device *pdev, void *priv_data)
>  {
>      int *is_kme = priv_data;
> 
> -    if (!(pdev->resource[0]->flags & IO_DATA_PATH_WIDTH_8)) {
> +    if ((pdev->resource[0]->flags & IO_DATA_PATH_WIDTH)
> +        != IO_DATA_PATH_WIDTH_8) {
>          pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
>          pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
>      }
> -- 

please patch until it is removed from the kernel code.
this will make checks happy and as fact of life such bug tend to show up
on surprising unpleasant times.

re,
 wh
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - June 11, 2012, 11:43 p.m.
From: Julia Lawall <julia.lawall@lip6.fr>
Date: Fri, 8 Jun 2012 07:14:03 +0200 (CEST)

> @@ -167,7 +167,8 @@ static int pcmcia_check_one_config(struct
> pcmcia_device *pdev, void *priv_data)

Patch mangled by your email client or similar.
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
index 28e344e..f1e922e 100644
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -167,7 +167,8 @@  static int pcmcia_check_one_config(struct pcmcia_device *pdev, void *priv_data)
  {
  	int *is_kme = priv_data;

-	if (!(pdev->resource[0]->flags & IO_DATA_PATH_WIDTH_8)) {
+	if ((pdev->resource[0]->flags & IO_DATA_PATH_WIDTH)
+	    != IO_DATA_PATH_WIDTH_8) {
  		pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
  		pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
  	}