nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0054-grub-core-disk-ahci.c-Properly-handle-transactions-w.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:49:51 +0100
4fe85b
Subject: [PATCH] * grub-core/disk/ahci.c: Properly handle transactions with no
4fe85b
 transferred data.
4fe85b
4fe85b
---
4fe85b
 grub-core/disk/ahci.c | 7 +++++--
4fe85b
 ChangeLog             | 5 +++++
4fe85b
 2 files changed, 10 insertions(+), 2 deletions(-)
4fe85b
4fe85b
diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c
4fe85b
index 643e691ef80..fdd40c64dd9 100644
4fe85b
--- a/grub-core/disk/ahci.c
4fe85b
+++ b/grub-core/disk/ahci.c
4fe85b
@@ -932,7 +932,10 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
4fe85b
   if (parms->size > GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH)
4fe85b
     return grub_error (GRUB_ERR_BUG, "too big data buffer");
4fe85b
 
4fe85b
-  bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1));
4fe85b
+  if (parms->size)
4fe85b
+    bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1));
4fe85b
+  else
4fe85b
+    bufc = grub_memalign_dma32 (1024, 512);
4fe85b
 
4fe85b
   grub_dprintf ("ahci", "AHCI tfd = %x, CL=%p\n",
4fe85b
 		dev->hba->ports[dev->port].task_file_data,
4fe85b
@@ -942,7 +945,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
4fe85b
     = (5 << GRUB_AHCI_CONFIG_CFIS_LENGTH_SHIFT)
4fe85b
     //    | GRUB_AHCI_CONFIG_CLEAR_R_OK
4fe85b
     | (0 << GRUB_AHCI_CONFIG_PMP_SHIFT)
4fe85b
-    | (1 << GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT)
4fe85b
+    | ((parms->size ? 1 : 0) << GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT)
4fe85b
     | (parms->cmdsize ? GRUB_AHCI_CONFIG_ATAPI : 0)
4fe85b
     | (parms->write ? GRUB_AHCI_CONFIG_WRITE : GRUB_AHCI_CONFIG_READ)
4fe85b
     | (parms->taskfile.cmd == 8 ? (1 << 8) : 0);
4fe85b
diff --git a/ChangeLog b/ChangeLog
4fe85b
index 15300b020c6..bc1ab231b02 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: Properly handle transactions with no
4fe85b
+	transferred data.
4fe85b
+
4fe85b
 2014-01-29  Vladimir Serbinenko  <phcoder@gmail.com>
4fe85b
 
4fe85b
 	* grub-core/disk/ahci.c: Add safety cleanups.