aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c
diff options
context:
space:
mode:
authorErnst Sjöstrand <ernstp@gmail.com>2017-11-19 12:52:44 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-12-06 12:47:59 -0500
commit7d0331007ab4bea446cf3d173410c3179b12e2ff (patch)
tree0e918b3a0fb8ccfa9303dc828480b9c52e7d4777 /drivers/gpu/drm/amd/amdgpu/atombios_i2c.c
parente9c227b253712db75b0623fe1596fec8c8857807 (diff)
drm/amd/amdgpu: Fix missing null check in atombios_i2c.c
Reported by smatch: amdgpu_atombios_i2c_process_i2c_ch() error: we previously assumed 'buf' could be null Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Ernst Sjöstrand <ernstp@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/atombios_i2c.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/atombios_i2c.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c b/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c
index b374653bd6cf..f9b2ce9a98f3 100644
--- a/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c
+++ b/drivers/gpu/drm/amd/amdgpu/atombios_i2c.c
@@ -65,8 +65,15 @@ static int amdgpu_atombios_i2c_process_i2c_ch(struct amdgpu_i2c_chan *chan,
65 args.ucRegIndex = buf[0]; 65 args.ucRegIndex = buf[0];
66 if (num) 66 if (num)
67 num--; 67 num--;
68 if (num) 68 if (num) {
69 memcpy(&out, &buf[1], num); 69 if (buf) {
70 memcpy(&out, &buf[1], num);
71 } else {
72 DRM_ERROR("hw i2c: missing buf with num > 1\n");
73 r = -EINVAL;
74 goto done;
75 }
76 }
70 args.lpI2CDataOut = cpu_to_le16(out); 77 args.lpI2CDataOut = cpu_to_le16(out);
71 } else { 78 } else {
72 if (num > ATOM_MAX_HW_I2C_READ) { 79 if (num > ATOM_MAX_HW_I2C_READ) {