* [patch] hwmon: using wrong ARRAY_SIZE() limit
@ 2013-07-17 12:26 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2013-07-17 12:26 UTC (permalink / raw)
To: kernel-janitors
We cleaned up this code to use ARRAY_SIZE() instead of just the number
4. The problem is that data->reg_temp[] has 5 elements and we actually
wanted ARRAY_SIZE(data->temp) which has 4 elements.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index f0941d7..52b6a92 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -1451,7 +1451,7 @@ static struct nct6775_data *nct6775_update_device(struct device *dev)
for (i = 0; i < NUM_TEMP; i++) {
if (!(data->have_temp & (1 << i)))
continue;
- for (j = 0; j < ARRAY_SIZE(data->reg_temp); j++) {
+ for (j = 0; j < ARRAY_SIZE(data->temp); j++) {
if (data->reg_temp[j][i])
data->temp[j][i]
= nct6775_read_temp(data,
@@ -3974,7 +3974,7 @@ static int nct6775_resume(struct device *dev)
if (!(data->have_temp & (1 << i)))
continue;
- for (j = 1; j < ARRAY_SIZE(data->reg_temp); j++)
+ for (j = 1; j < ARRAY_SIZE(data->temp); j++)
if (data->reg_temp[j][i])
nct6775_write_temp(data, data->reg_temp[j][i],
data->temp[j][i]);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [lm-sensors] [patch] hwmon: using wrong ARRAY_SIZE() limit
@ 2013-07-17 12:26 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2013-07-17 12:26 UTC (permalink / raw)
To: kernel-janitors
We cleaned up this code to use ARRAY_SIZE() instead of just the number
4. The problem is that data->reg_temp[] has 5 elements and we actually
wanted ARRAY_SIZE(data->temp) which has 4 elements.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index f0941d7..52b6a92 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -1451,7 +1451,7 @@ static struct nct6775_data *nct6775_update_device(struct device *dev)
for (i = 0; i < NUM_TEMP; i++) {
if (!(data->have_temp & (1 << i)))
continue;
- for (j = 0; j < ARRAY_SIZE(data->reg_temp); j++) {
+ for (j = 0; j < ARRAY_SIZE(data->temp); j++) {
if (data->reg_temp[j][i])
data->temp[j][i]
= nct6775_read_temp(data,
@@ -3974,7 +3974,7 @@ static int nct6775_resume(struct device *dev)
if (!(data->have_temp & (1 << i)))
continue;
- for (j = 1; j < ARRAY_SIZE(data->reg_temp); j++)
+ for (j = 1; j < ARRAY_SIZE(data->temp); j++)
if (data->reg_temp[j][i])
nct6775_write_temp(data, data->reg_temp[j][i],
data->temp[j][i]);
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [patch] hwmon: using wrong ARRAY_SIZE() limit
2013-07-17 12:26 ` [lm-sensors] " Dan Carpenter
@ 2013-07-17 23:36 ` Guenter Roeck
-1 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2013-07-17 23:36 UTC (permalink / raw)
To: kernel-janitors
On Wed, Jul 17, 2013 at 03:26:14PM +0300, Dan Carpenter wrote:
> We cleaned up this code to use ARRAY_SIZE() instead of just the number
> 4. The problem is that data->reg_temp[] has 5 elements and we actually
> wanted ARRAY_SIZE(data->temp) which has 4 elements.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
Hi Dan,
good catch, except that the array size of data->temp[] should be 5, not 4.
So the real culprit is commit 7cbbd6a (Add support for critical low/high
temperature limits on NCT6106) which increased the size of reg_temp but not the
size of temp.
Do you want to send me a patch fixing that, or should I take care of it ?
Thanks,
Guenter
> diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
> index f0941d7..52b6a92 100644
> --- a/drivers/hwmon/nct6775.c
> +++ b/drivers/hwmon/nct6775.c
> @@ -1451,7 +1451,7 @@ static struct nct6775_data *nct6775_update_device(struct device *dev)
> for (i = 0; i < NUM_TEMP; i++) {
> if (!(data->have_temp & (1 << i)))
> continue;
> - for (j = 0; j < ARRAY_SIZE(data->reg_temp); j++) {
> + for (j = 0; j < ARRAY_SIZE(data->temp); j++) {
> if (data->reg_temp[j][i])
> data->temp[j][i]
> = nct6775_read_temp(data,
> @@ -3974,7 +3974,7 @@ static int nct6775_resume(struct device *dev)
> if (!(data->have_temp & (1 << i)))
> continue;
>
> - for (j = 1; j < ARRAY_SIZE(data->reg_temp); j++)
> + for (j = 1; j < ARRAY_SIZE(data->temp); j++)
> if (data->reg_temp[j][i])
> nct6775_write_temp(data, data->reg_temp[j][i],
> data->temp[j][i]);
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] [patch] hwmon: using wrong ARRAY_SIZE() limit
@ 2013-07-17 23:36 ` Guenter Roeck
0 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2013-07-17 23:36 UTC (permalink / raw)
To: kernel-janitors
On Wed, Jul 17, 2013 at 03:26:14PM +0300, Dan Carpenter wrote:
> We cleaned up this code to use ARRAY_SIZE() instead of just the number
> 4. The problem is that data->reg_temp[] has 5 elements and we actually
> wanted ARRAY_SIZE(data->temp) which has 4 elements.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
Hi Dan,
good catch, except that the array size of data->temp[] should be 5, not 4.
So the real culprit is commit 7cbbd6a (Add support for critical low/high
temperature limits on NCT6106) which increased the size of reg_temp but not the
size of temp.
Do you want to send me a patch fixing that, or should I take care of it ?
Thanks,
Guenter
> diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
> index f0941d7..52b6a92 100644
> --- a/drivers/hwmon/nct6775.c
> +++ b/drivers/hwmon/nct6775.c
> @@ -1451,7 +1451,7 @@ static struct nct6775_data *nct6775_update_device(struct device *dev)
> for (i = 0; i < NUM_TEMP; i++) {
> if (!(data->have_temp & (1 << i)))
> continue;
> - for (j = 0; j < ARRAY_SIZE(data->reg_temp); j++) {
> + for (j = 0; j < ARRAY_SIZE(data->temp); j++) {
> if (data->reg_temp[j][i])
> data->temp[j][i]
> = nct6775_read_temp(data,
> @@ -3974,7 +3974,7 @@ static int nct6775_resume(struct device *dev)
> if (!(data->have_temp & (1 << i)))
> continue;
>
> - for (j = 1; j < ARRAY_SIZE(data->reg_temp); j++)
> + for (j = 1; j < ARRAY_SIZE(data->temp); j++)
> if (data->reg_temp[j][i])
> nct6775_write_temp(data, data->reg_temp[j][i],
> data->temp[j][i]);
>
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] hwmon: using wrong ARRAY_SIZE() limit
2013-07-17 12:26 ` [lm-sensors] " Dan Carpenter
@ 2013-07-18 15:41 ` walter harms
-1 siblings, 0 replies; 8+ messages in thread
From: walter harms @ 2013-07-18 15:41 UTC (permalink / raw)
To: kernel-janitors
Am 18.07.2013 01:36, schrieb Guenter Roeck:
> On Wed, Jul 17, 2013 at 03:26:14PM +0300, Dan Carpenter wrote:
>> We cleaned up this code to use ARRAY_SIZE() instead of just the number
>> 4. The problem is that data->reg_temp[] has 5 elements and we actually
>> wanted ARRAY_SIZE(data->temp) which has 4 elements.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>
> Hi Dan,
>
> good catch, except that the array size of data->temp[] should be 5, not 4.
> So the real culprit is commit 7cbbd6a (Add support for critical low/high
> temperature limits on NCT6106) which increased the size of reg_temp but not the
> size of temp.
>
> Do you want to send me a patch fixing that, or should I take care of it ?
>
> Thanks,
> Guenter
hi Guenther,
is an array the way to go here ? To avoid that kind of problems they sould be
connected some how. Is it possible to replace the array with a malloc() ?
re,
wh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] [patch] hwmon: using wrong ARRAY_SIZE() limit
@ 2013-07-18 15:41 ` walter harms
0 siblings, 0 replies; 8+ messages in thread
From: walter harms @ 2013-07-18 15:41 UTC (permalink / raw)
To: kernel-janitors
Am 18.07.2013 01:36, schrieb Guenter Roeck:
> On Wed, Jul 17, 2013 at 03:26:14PM +0300, Dan Carpenter wrote:
>> We cleaned up this code to use ARRAY_SIZE() instead of just the number
>> 4. The problem is that data->reg_temp[] has 5 elements and we actually
>> wanted ARRAY_SIZE(data->temp) which has 4 elements.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>
> Hi Dan,
>
> good catch, except that the array size of data->temp[] should be 5, not 4.
> So the real culprit is commit 7cbbd6a (Add support for critical low/high
> temperature limits on NCT6106) which increased the size of reg_temp but not the
> size of temp.
>
> Do you want to send me a patch fixing that, or should I take care of it ?
>
> Thanks,
> Guenter
hi Guenther,
is an array the way to go here ? To avoid that kind of problems they sould be
connected some how. Is it possible to replace the array with a malloc() ?
re,
wh
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] hwmon: using wrong ARRAY_SIZE() limit
2013-07-17 12:26 ` [lm-sensors] " Dan Carpenter
@ 2013-07-18 20:43 ` Guenter Roeck
-1 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2013-07-18 20:43 UTC (permalink / raw)
To: kernel-janitors
On Thu, Jul 18, 2013 at 05:41:08PM +0200, walter harms wrote:
>
>
> Am 18.07.2013 01:36, schrieb Guenter Roeck:
> > On Wed, Jul 17, 2013 at 03:26:14PM +0300, Dan Carpenter wrote:
> >> We cleaned up this code to use ARRAY_SIZE() instead of just the number
> >> 4. The problem is that data->reg_temp[] has 5 elements and we actually
> >> wanted ARRAY_SIZE(data->temp) which has 4 elements.
> >>
> >> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >>
> > Hi Dan,
> >
> > good catch, except that the array size of data->temp[] should be 5, not 4.
> > So the real culprit is commit 7cbbd6a (Add support for critical low/high
> > temperature limits on NCT6106) which increased the size of reg_temp but not the
> > size of temp.
> >
> > Do you want to send me a patch fixing that, or should I take care of it ?
> >
> > Thanks,
> > Guenter
>
> hi Guenther,
> is an array the way to go here ? To avoid that kind of problems they sould be
> connected some how. Is it possible to replace the array with a malloc() ?
>
To clean it up I should probably add a define for the array sizes. A malloc
would be overkill.
Guenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [lm-sensors] [patch] hwmon: using wrong ARRAY_SIZE() limit
@ 2013-07-18 20:43 ` Guenter Roeck
0 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2013-07-18 20:43 UTC (permalink / raw)
To: kernel-janitors
On Thu, Jul 18, 2013 at 05:41:08PM +0200, walter harms wrote:
>
>
> Am 18.07.2013 01:36, schrieb Guenter Roeck:
> > On Wed, Jul 17, 2013 at 03:26:14PM +0300, Dan Carpenter wrote:
> >> We cleaned up this code to use ARRAY_SIZE() instead of just the number
> >> 4. The problem is that data->reg_temp[] has 5 elements and we actually
> >> wanted ARRAY_SIZE(data->temp) which has 4 elements.
> >>
> >> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >>
> > Hi Dan,
> >
> > good catch, except that the array size of data->temp[] should be 5, not 4.
> > So the real culprit is commit 7cbbd6a (Add support for critical low/high
> > temperature limits on NCT6106) which increased the size of reg_temp but not the
> > size of temp.
> >
> > Do you want to send me a patch fixing that, or should I take care of it ?
> >
> > Thanks,
> > Guenter
>
> hi Guenther,
> is an array the way to go here ? To avoid that kind of problems they sould be
> connected some how. Is it possible to replace the array with a malloc() ?
>
To clean it up I should probably add a define for the array sizes. A malloc
would be overkill.
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-07-18 20:43 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-17 12:26 [patch] hwmon: using wrong ARRAY_SIZE() limit Dan Carpenter
2013-07-17 12:26 ` [lm-sensors] " Dan Carpenter
2013-07-17 23:36 ` Guenter Roeck
2013-07-17 23:36 ` [lm-sensors] " Guenter Roeck
2013-07-18 15:41 ` walter harms
2013-07-18 15:41 ` [lm-sensors] " walter harms
2013-07-18 20:43 ` Guenter Roeck
2013-07-18 20:43 ` [lm-sensors] " Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.