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

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