lkml.org 
[lkml]   [2011]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] w1: off by one in w1_f29_remove_slave()


Am 29.07.2011 22:28, schrieb Jean-François Dagenais:
> Yup, confirmed, weird that I did not notice a crash, probably lucky shot in the environment I was using it.
>
> On 2011-07-27, at 05:55, Dan Carpenter wrote:
>
>> This reads past the end of the w1_f29_sysfs_bin_files[] array. I
>> don't have this hardware, but I assume it crashes every time the
>> function is called.
>>
>> Signed-off-by: Dan Carpenter <error27@gmail.com>
> Acked-by: Jean-François Dagenais <dagenaisj@sonatest.com>
>>
>> diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c
>> index c377818..0da4e97 100644
>> --- a/drivers/w1/slaves/w1_ds2408.c
>> +++ b/drivers/w1/slaves/w1_ds2408.c
>> @@ -373,7 +373,7 @@ static int w1_f29_add_slave(struct w1_slave *sl)
>> static void w1_f29_remove_slave(struct w1_slave *sl)
>> {
>> int i;
>> - for (i = NB_SYSFS_BIN_FILES; i <= 0; --i)
>> + for (i = NB_SYSFS_BIN_FILES - 1; i <= 0; --i)
>> sysfs_remove_bin_file(&sl->dev.kobj,
>> &(w1_f29_sysfs_bin_files[i]));
>> }


Is there any reason to release the data "backwards" ?
The default way is to go upwards. that looks more readable.

for (i=0; i < NB_SYSFS_BIN_FILES ; i++)
sysfs_remove_bin_file(&sl->dev.kobj, w1_f29_sysfs_bin_files+i);

re,
wh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2011-07-30 10:45    [W:0.123 / U:0.664 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site