nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0052-grub-core-disk-ahci.c-Allocate-and-clean-space-for-a.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Vladimir Serbinenko <phcoder@gmail.com>
4fe85b
Date: Wed, 29 Jan 2014 23:45:18 +0100
4fe85b
Subject: [PATCH] * grub-core/disk/ahci.c: Allocate and clean space for all
4fe85b
 possible 32 slots to avoid pointing to uninited area.
4fe85b
4fe85b
---
4fe85b
 grub-core/disk/ahci.c | 8 +++++++-
4fe85b
 ChangeLog             | 5 +++++
4fe85b
 2 files changed, 12 insertions(+), 1 deletion(-)
4fe85b
4fe85b
diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c
4fe85b
index 18c13270c65..d63fd09fdc6 100644
4fe85b
--- a/grub-core/disk/ahci.c
4fe85b
+++ b/grub-core/disk/ahci.c
4fe85b
@@ -358,7 +358,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
4fe85b
 	grub_dprintf ("ahci", "err: %x\n",
4fe85b
 		      adevs[i]->hba->ports[adevs[i]->port].sata_error);
4fe85b
 
4fe85b
-	adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head));
4fe85b
+	adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head) * 32);
4fe85b
 	if (!adevs[i]->command_list_chunk)
4fe85b
 	  {
4fe85b
 	    adevs[i] = 0;
4fe85b
@@ -376,6 +376,12 @@ grub_ahci_pciinit (grub_pci_device_t dev,
4fe85b
 
4fe85b
 	adevs[i]->command_list = grub_dma_get_virt (adevs[i]->command_list_chunk);
4fe85b
 	adevs[i]->command_table = grub_dma_get_virt (adevs[i]->command_table_chunk);
4fe85b
+
4fe85b
+	grub_memset ((void *) adevs[i]->command_list, 0,
4fe85b
+		     sizeof (struct grub_ahci_cmd_table));
4fe85b
+	grub_memset ((void *) adevs[i]->command_table, 0,
4fe85b
+		     sizeof (struct grub_ahci_cmd_head) * 32);
4fe85b
+
4fe85b
 	adevs[i]->command_list->command_table_base
4fe85b
 	  = grub_dma_get_phys (adevs[i]->command_table_chunk);
4fe85b
 
4fe85b
diff --git a/ChangeLog b/ChangeLog
4fe85b
index 51eba95f36f..9bb18177793 100644
4fe85b
--- a/ChangeLog
4fe85b
+++ b/ChangeLog
4fe85b
@@ -1,3 +1,8 @@
4fe85b
+2014-01-29  Vladimir Serbinenko  <phcoder@gmail.com>
4fe85b
+
4fe85b
+	* grub-core/disk/ahci.c: Allocate and clean space for all possible 32
4fe85b
+	slots to avoid pointing to uninited area.
4fe85b
+
4fe85b
 2014-01-29  Vladimir Serbinenko  <phcoder@gmail.com>
4fe85b
 
4fe85b
 	* grub-core/disk/ahci.c: Do not enable I/O decoding and keep