[Arm-dev] [PATCH 06/11] Integrate fix to avoid DMA buffer overrun on X-Gene SlimPRO I2C driver

Fri Nov 11 02:47:48 UTC 2016
Duc Dang <dhdang at apm.com>

Also reorder the X-Gene change log so that the newest change
is on the top.

Signed-off-by: Duc Dang <dhdang at apm.com>
---
 .../1010-i2c-xgene-Avoid-dma_buffer-overrun.patch  | 32 ++++++++++++++++++++++
 SPECS/kernel-aarch64.spec                          |  9 ++++--
 2 files changed, 38 insertions(+), 3 deletions(-)
 create mode 100644 SOURCES/1010-i2c-xgene-Avoid-dma_buffer-overrun.patch

diff --git a/SOURCES/1010-i2c-xgene-Avoid-dma_buffer-overrun.patch b/SOURCES/1010-i2c-xgene-Avoid-dma_buffer-overrun.patch
new file mode 100644
index 0000000..d0744ea
--- /dev/null
+++ b/SOURCES/1010-i2c-xgene-Avoid-dma_buffer-overrun.patch
@@ -0,0 +1,32 @@
+From 24d0e4ddc132c6fc502c1d2465808fc007eb4dd1 Mon Sep 17 00:00:00 2001
+From: Hoan Tran <hotran at apm.com>
+Date: Mon, 10 Oct 2016 10:13:10 -0700
+Subject: [PATCH 1010/1018] i2c: xgene: Avoid dma_buffer overrun
+
+SMBus block command uses the first byte of buffer for the data length.
+The dma_buffer should be increased by 1 to avoid the overrun issue.
+
+Reported-by: Phil Endecott <phil_gjouf_endecott at chezphil.org>
+Signed-off-by: Hoan Tran <hotran at apm.com>
+Signed-off-by: Wolfram Sang <wsa at the-dreams.de>
+Cc: stable at kernel.org
+---
+ drivers/i2c/busses/i2c-xgene-slimpro.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c b/drivers/i2c/busses/i2c-xgene-slimpro.c
+index 4233f56..3c38029 100644
+--- a/drivers/i2c/busses/i2c-xgene-slimpro.c
++++ b/drivers/i2c/busses/i2c-xgene-slimpro.c
+@@ -105,7 +105,7 @@ struct slimpro_i2c_dev {
+ 	struct mbox_chan *mbox_chan;
+ 	struct mbox_client mbox_client;
+ 	struct completion rd_complete;
+-	u8 dma_buffer[I2C_SMBUS_BLOCK_MAX];
++	u8 dma_buffer[I2C_SMBUS_BLOCK_MAX + 1]; /* dma_buffer[0] is used for length */
+ 	u32 *resp_msg;
+ };
+ 
+-- 
+1.8.3.1
+
diff --git a/SPECS/kernel-aarch64.spec b/SPECS/kernel-aarch64.spec
index 894cd55..84374b8 100644
--- a/SPECS/kernel-aarch64.spec
+++ b/SPECS/kernel-aarch64.spec
@@ -334,6 +334,7 @@ Patch1006: 1006-hwmon-xgene-Fix-crash-when-alarm-occurs-before-drive.patch
 Patch1007: 1007-perf-xgene-Add-APM-X-Gene-SoC-Performance-Monitoring.patch
 Patch1008: 1008-perf-xgene-Remove-bogus-IS_ERR-check.patch
 Patch1009: 1009-MAINTAINERS-Add-entry-for-APM-X-Gene-SoC-PMU-driver.patch
+Patch1010: 1010-i2c-xgene-Avoid-dma_buffer-overrun.patch
 
 # QDF2400 Patches
 Patch4000: 4000-arm64-Define-Qualcomm-Technologies-ARMv8-CPU.patch
@@ -678,6 +679,7 @@ git am %{PATCH1006}
 git am %{PATCH1007}
 git am %{PATCH1008}
 git am %{PATCH1009}
+git am %{PATCH1010}
 
 # Apply QDF2400 patches
 git am %{PATCH4000}
@@ -1457,10 +1459,11 @@ fi
 
 %changelog
 * Thu Nov 10 2016 Duc Dang <dhdang at apm.com> [4.5.0-17.el7]
-- Add cpufreq CPPC bug fixes
-- mailbox: PCC: Fix return value of pcc_mbox_request_channel
-- Add X-Gene HWMon support
+- Avoid dma_buffer overrun for SlimPRO I2C driver 
 - Add X-Gene SoC PMU support
+- Add X-Gene HWMon support
+- mailbox: PCC: Fix return value of pcc_mbox_request_channel
+- Add cpufreq CPPC bug fixes
 
 * Mon Nov 07 2016 Christopher Covington <cov at codeaurora.org> [4.5.0-16.el7]
 - Add git machinery (Jim Perrin)
-- 
1.8.3.1