Skip to contentSkip to conversation

Off by one in drivers/block/floppy.c

PATCH New Eric Sesterhenn 1 participant 1 message Jun 27, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Off by one in drivers/block/floppy.c

hi,

another bug spotted by coverity (id #481). In the case that drive == N_DRIVE we acess past the drive_params array which is defined as drive_params[N_DRIVE]. By using the UDP define in the else case because UDP is &drive_params[drive]

drivers/block/floppy.c renamed from drivers/block/floppy.c.orig +1 -1
@@ -684,7 +684,7 @@ static void __reschedule_timeout(int dri
 	if (drive == current_reqD)
 		drive = current_drive;
 	del_timer(&fd_timeout);
-	if (drive < 0 || drive > N_DRIVE) {
+	if (drive < 0 || drive > N_DRIVE-1) {
 		fd_timeout.expires = jiffies + 20UL * HZ;
 		drive = 0;
 	} else