From: Dan Carpenter Date: Thu, 25 Aug 2011 22:59:04 +0000 (-0700) Subject: w1: fix for loop in w1_f29_remove_slave() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=58299449257566613f58dcfb757f0ba4a377987a;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git w1: fix for loop in w1_f29_remove_slave() The for loop was looking for i <= 0 instead of i >= 0 so this function never did anything. Also we started with i = NB_SYSFS_BIN_FILES instead of "NB_SYSFS_BIN_FILES - 1" which is an off by one bug. Reported-by: Bojan Prtvar Signed-off-by: Dan Carpenter Acked-by: Jean-Franois Dagenais Cc: Evgeniy Polyakov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c index c37781899d9..7c8cdb8aed2 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])); }