aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0842-drm-amd-dal-fix-memory-leaks-in-I2C-code.patch
diff options
context:
space:
mode:
Diffstat (limited to 'common/recipes-kernel/linux/files/0842-drm-amd-dal-fix-memory-leaks-in-I2C-code.patch')
-rw-r--r--common/recipes-kernel/linux/files/0842-drm-amd-dal-fix-memory-leaks-in-I2C-code.patch84
1 files changed, 84 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/files/0842-drm-amd-dal-fix-memory-leaks-in-I2C-code.patch b/common/recipes-kernel/linux/files/0842-drm-amd-dal-fix-memory-leaks-in-I2C-code.patch
new file mode 100644
index 00000000..bd3a533e
--- /dev/null
+++ b/common/recipes-kernel/linux/files/0842-drm-amd-dal-fix-memory-leaks-in-I2C-code.patch
@@ -0,0 +1,84 @@
+From eed795bce45f220f363abebbf87fac8a52877e16 Mon Sep 17 00:00:00 2001
+From: Mykola Lysenko <Mykola.Lysenko@amd.com>
+Date: Fri, 26 Feb 2016 04:04:07 -0500
+Subject: [PATCH 0842/1110] drm/amd/dal: fix memory leaks in I2C code
+
+Two memory leaks were fixed
+
+Signed-off-by: Mykola Lysenko <Mykola.Lysenko@amd.com>
+Acked-by: Harry Wentland <harry.wentland@amd.com>
+---
+ drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_helpers.c | 10 +++++++++-
+ drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c | 13 ++++++++++---
+ 2 files changed, 19 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_helpers.c
+index e414861..17240e0 100644
+--- a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_helpers.c
++++ b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_helpers.c
+@@ -515,6 +515,7 @@ bool dm_helpers_submit_i2c(
+ struct i2c_msg *msgs;
+ int i = 0;
+ int num = cmd->number_of_payloads;
++ bool result;
+
+ if (!aconnector) {
+ DRM_ERROR("Failed to found connector for link!");
+@@ -523,6 +524,9 @@ bool dm_helpers_submit_i2c(
+
+ msgs = kzalloc(num * sizeof(struct i2c_msg), GFP_KERNEL);
+
++ if (!msgs)
++ return false;
++
+ for (i = 0; i < num; i++) {
+ msgs[i].flags = cmd->payloads[i].write ? I2C_M_RD : 0;
+ msgs[i].addr = cmd->payloads[i].address;
+@@ -530,6 +534,10 @@ bool dm_helpers_submit_i2c(
+ msgs[i].buf = cmd->payloads[i].data;
+ }
+
+- return i2c_transfer(&aconnector->i2c->base, msgs, num) == num;
++ result = i2c_transfer(&aconnector->i2c->base, msgs, num) == num;
++
++ kfree(msgs);
++
++ return result;
+ }
+
+diff --git a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
+index ec02029..f0eaafd 100644
+--- a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
++++ b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
+@@ -1814,8 +1814,13 @@ int amdgpu_dm_i2c_xfer(struct i2c_adapter *i2c_adap,
+ struct amdgpu_i2c_adapter *i2c = i2c_get_adapdata(i2c_adap);
+ struct i2c_command cmd;
+ int i;
++ int result = -EIO;
+
+ cmd.payloads = kzalloc(num * sizeof(struct i2c_payload), GFP_KERNEL);
++
++ if (!cmd.payloads)
++ return result;
++
+ cmd.number_of_payloads = num;
+ cmd.engine = I2C_COMMAND_ENGINE_DEFAULT;
+ cmd.speed = 100;
+@@ -1828,9 +1833,11 @@ int amdgpu_dm_i2c_xfer(struct i2c_adapter *i2c_adap,
+ }
+
+ if (dc_submit_i2c(i2c->dm->dc, i2c->link_index, &cmd))
+- return num;
+- else
+- return -EIO;
++ result = num;
++
++ kfree(cmd.payloads);
++
++ return result;
+ }
+
+ u32 amdgpu_dm_i2c_func(struct i2c_adapter *adap)
+--
+2.7.4
+