This patch fixes a negative array index spotted by the Coverity checker.
Signed-off-by: Adrian Bunk <[email protected]>
---
I'm not 100% sure whether my patch is correct, but if not this patch is
the easiest way to show the problem.
--- linux-2.6/drivers/net/wireless/ath5k/phy.c.old 2008-02-02 21:44:58.000000000 +0200
+++ linux-2.6/drivers/net/wireless/ath5k/phy.c 2008-02-02 21:48:28.000000000 +0200
@@ -1176,10 +1176,13 @@ static int ath5k_hw_rf5112_rfregs(struct
obdb = channel->freq >= 5725 ? 3 :
(channel->freq >= 5500 ? 2 :
(channel->freq >= 5260 ? 1 :
(channel->freq > 4000 ? 0 : -1)));
+ if (obdb == -1)
+ return -EINVAL;
+
if (!ath5k_hw_rfregs_op(rf, ah->ah_offset[6],
ee->ee_ob[ee_mode][obdb], 3, 279, 0, true))
return -EINVAL;
if (!ath5k_hw_rfregs_op(rf, ah->ah_offset[6],
On Feb 2, 2008 4:38 PM, Nick Kossifidis <[email protected]> wrote:
> 2008/2/2, Adrian Bunk <[email protected]>:
>
> > This patch fixes a negative array index spotted by the Coverity checker.
> >
> > Signed-off-by: Adrian Bunk <[email protected]>
> >
> > ---
> >
> > I'm not 100% sure whether my patch is correct, but if not this patch is
> > the easiest way to show the problem.
> >
> > --- linux-2.6/drivers/net/wireless/ath5k/phy.c.old 2008-02-02 21:44:58.000000000 +0200
> > +++ linux-2.6/drivers/net/wireless/ath5k/phy.c 2008-02-02 21:48:28.000000000 +0200
> > @@ -1176,10 +1176,13 @@ static int ath5k_hw_rf5112_rfregs(struct
> > obdb = channel->freq >= 5725 ? 3 :
> > (channel->freq >= 5500 ? 2 :
> > (channel->freq >= 5260 ? 1 :
> > (channel->freq > 4000 ? 0 : -1)));
> >
> > + if (obdb == -1)
> > + return -EINVAL;
> > +
> > if (!ath5k_hw_rfregs_op(rf, ah->ah_offset[6],
> > ee->ee_ob[ee_mode][obdb], 3, 279, 0, true))
> > return -EINVAL;
> >
> > if (!ath5k_hw_rfregs_op(rf, ah->ah_offset[6],
> >
>
> Thanx ;-)
>
> Acked-by: Nick Kossifidis <[email protected]>
This won't apply after the API changes, I'll port it and send it as
part of the series.
Thanks,
Luis
2008/2/2, Adrian Bunk <[email protected]>:
> This patch fixes a negative array index spotted by the Coverity checker.
>
> Signed-off-by: Adrian Bunk <[email protected]>
>
> ---
>
> I'm not 100% sure whether my patch is correct, but if not this patch is
> the easiest way to show the problem.
>
> --- linux-2.6/drivers/net/wireless/ath5k/phy.c.old 2008-02-02 21:44:58.000000000 +0200
> +++ linux-2.6/drivers/net/wireless/ath5k/phy.c 2008-02-02 21:48:28.000000000 +0200
> @@ -1176,10 +1176,13 @@ static int ath5k_hw_rf5112_rfregs(struct
> obdb = channel->freq >= 5725 ? 3 :
> (channel->freq >= 5500 ? 2 :
> (channel->freq >= 5260 ? 1 :
> (channel->freq > 4000 ? 0 : -1)));
>
> + if (obdb == -1)
> + return -EINVAL;
> +
> if (!ath5k_hw_rfregs_op(rf, ah->ah_offset[6],
> ee->ee_ob[ee_mode][obdb], 3, 279, 0, true))
> return -EINVAL;
>
> if (!ath5k_hw_rfregs_op(rf, ah->ah_offset[6],
>
Thanx ;-)
Acked-by: Nick Kossifidis <[email protected]>
--
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-)
Nick