[PATCH 2.4.33-rc1] repair __ide_dma_no_op breakage

Linux Kernel Mailing List <[email protected]> Mon, 19 Jun 2006 22:59:02 GMT
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
commit 1e5c3464495dc22d706bc1fc04293956357b47f6
tree 5e60558449398acc976a270342ae630416187d8a
parent 773a34c6501234f0c9759a520f32f5e3b9bf24a3
author Mikael Pettersson <[email protected]> Sat, 17 Jun 2006 22:47:53 +0200
committer Willy Tarreau <willy@pcw.(none)> Sat, 17 Jun 2006 23:15:11 +0200

[PATCH 2.4.33-rc1] repair __ide_dma_no_op breakage

> Willy TARREAU:
>      ide: trying to enable DMA may cause an oops

This patch to ide-dma.c defines a function 'int __ide_dma_no_op(void)'
and stores its address in function pointer fields with type
'int (*)(ide_drive_t*)'. Thus callers will call __ide_dma_no_op() with
more parameters than it expects.

This is invalid C and it will break horribly in some valid calling
conventions (in particular, when parameters are passed on the stack
and the callee not the caller pops them).

Furtunately the fix is simple: just define __ide_dma_no_op() with
the correct prototype (taking an unused ide_drive_t* parameter),
and drop the now redundant casts from the assignments. Also make
__ide_dma_no_op() 'static' as it is local to ide-dma.c.

Signed-off-by: Mikael Pettersson <[email protected]>


 drivers/ide/ide-dma.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 9431392..7126888 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -572,7 +572,7 @@ static int dma_timer_expiry (ide_drive_t
  *	This empty function prevents non-DMA controllers from causing an oops.
  */
 
-int __ide_dma_no_op (void)
+static int __ide_dma_no_op (ide_drive_t *ignored)
 {
 	return 0;
 }
@@ -1235,11 +1235,11 @@ EXPORT_SYMBOL_GPL(ide_setup_dma);
 void ide_setup_no_dma (ide_hwif_t *hwif)
 {
 	if (!hwif->ide_dma_off_quietly)
-		hwif->ide_dma_off_quietly = (int (*)(ide_drive_t *))&__ide_dma_no_op;
+		hwif->ide_dma_off_quietly = &__ide_dma_no_op;
 	if (!hwif->ide_dma_host_off)
-		hwif->ide_dma_host_off = (int (*)(ide_drive_t *))&__ide_dma_no_op;
+		hwif->ide_dma_host_off = &__ide_dma_no_op;
 	if (!hwif->ide_dma_host_on)
-		hwif->ide_dma_host_on = (int (*)(ide_drive_t *))&__ide_dma_no_op;
+		hwif->ide_dma_host_on = &__ide_dma_no_op;
 }
 
 EXPORT_SYMBOL_GPL(ide_setup_no_dma);