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