public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.4.32 Don't panic on IDE DMA errors
@ 2005-11-23 15:56 Chris Ross
  2005-11-28 12:06 ` Marcelo Tosatti
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Ross @ 2005-11-23 15:56 UTC (permalink / raw)
  To: Andre Hedrick, Marcelo Tosatti, Greg Ungerer,
	Linux Kernel Mailing List, linux-arm-kernel, Russell King

Kernel 2.4.32 and earlier can panic when trying to read a corrupted 
sector from an IDE disk.

The function ide_dma_timeout_retry can end a request early by calling 
idedisk_error, but then goes on to use the request anyway causing a 
kernel panic due to a null pointer exception. This patch fixes that.

Regards,
Chris R.


diff -urN -X dontdiff linux-2.4.32/drivers/ide/ide-io.c 
patched-linux-2.4.32/drivers/ide/ide-io.c
--- linux-2.4.32/drivers/ide/ide-io.c	2003-11-28 18:26:20.000000000 +0000
+++ patched-linux-2.4.32/drivers/ide/ide-io.c	2005-11-23 
12:33:37.000000000 +0000
@@ -899,11 +899,13 @@
  	rq = HWGROUP(drive)->rq;
  	HWGROUP(drive)->rq = NULL;

-	rq->errors = 0;
-	rq->sector = rq->bh->b_rsector;
-	rq->current_nr_sectors = rq->bh->b_size >> 9;
-	rq->hard_cur_sectors = rq->current_nr_sectors;
-	rq->buffer = rq->bh->b_data;
+	if (rq) {
+		rq->errors = 0;
+		rq->sector = rq->bh->b_rsector;
+		rq->current_nr_sectors = rq->bh->b_size >> 9;
+		rq->hard_cur_sectors = rq->current_nr_sectors;
+		rq->buffer = rq->bh->b_data;
+	}

  	return ret;
  }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] 2.4.32 Don't panic on IDE DMA errors
  2005-11-23 15:56 [PATCH] 2.4.32 Don't panic on IDE DMA errors Chris Ross
@ 2005-11-28 12:06 ` Marcelo Tosatti
  0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2005-11-28 12:06 UTC (permalink / raw)
  To: Chris Ross
  Cc: Andre Hedrick, Greg Ungerer, Linux Kernel Mailing List,
	linux-arm-kernel, Russell King


Applied, thanks Chris.

On Wed, Nov 23, 2005 at 03:56:00PM +0000, Chris Ross wrote:
> Kernel 2.4.32 and earlier can panic when trying to read a corrupted 
> sector from an IDE disk.
> 
> The function ide_dma_timeout_retry can end a request early by calling 
> idedisk_error, but then goes on to use the request anyway causing a 
> kernel panic due to a null pointer exception. This patch fixes that.
> 
> Regards,
> Chris R.
> 
> 
> diff -urN -X dontdiff linux-2.4.32/drivers/ide/ide-io.c 
> patched-linux-2.4.32/drivers/ide/ide-io.c
> --- linux-2.4.32/drivers/ide/ide-io.c	2003-11-28 18:26:20.000000000 +0000
> +++ patched-linux-2.4.32/drivers/ide/ide-io.c	2005-11-23 
> 12:33:37.000000000 +0000
> @@ -899,11 +899,13 @@
>  	rq = HWGROUP(drive)->rq;
>  	HWGROUP(drive)->rq = NULL;
> 
> -	rq->errors = 0;
> -	rq->sector = rq->bh->b_rsector;
> -	rq->current_nr_sectors = rq->bh->b_size >> 9;
> -	rq->hard_cur_sectors = rq->current_nr_sectors;
> -	rq->buffer = rq->bh->b_data;
> +	if (rq) {
> +		rq->errors = 0;
> +		rq->sector = rq->bh->b_rsector;
> +		rq->current_nr_sectors = rq->bh->b_size >> 9;
> +		rq->hard_cur_sectors = rq->current_nr_sectors;
> +		rq->buffer = rq->bh->b_data;
> +	}
> 
>  	return ret;
>  }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-11-28 17:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-23 15:56 [PATCH] 2.4.32 Don't panic on IDE DMA errors Chris Ross
2005-11-28 12:06 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox