summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_dp.c
diff options
context:
space:
mode:
authorImre Deak <imre.deak@intel.com>2016-01-29 14:52:26 +0200
committerImre Deak <imre.deak@intel.com>2016-02-02 18:28:20 +0200
commitd81a67cc1bfdc3efed8590ee4e07a40b198908ba (patch)
tree77fb04360979d9ab1cc132bc369d4c494a64c55c /drivers/gpu/drm/i915/intel_dp.c
parent985dd4360fdf2533fe48a33a4a2094f2e4718dc0 (diff)
downloadop-kernel-dev-d81a67cc1bfdc3efed8590ee4e07a40b198908ba.zip
op-kernel-dev-d81a67cc1bfdc3efed8590ee4e07a40b198908ba.tar.gz
drm/i915: Sanity check DP AUX message buffer and size
While we are calling intel_dp_aux_transfer() with msg->size=0 whenever msg->buffer is NULL, passing NULL to memcpy() is undefined according to the ISO C standard. I haven't found any notes about this in the GNU C's or the kernel's documentation of the function and can't imagine what it would do with the NULL ptr. To better document this use of the parameters it still make sense to add an explicit check for this to the code. Signed-off-by: Imre Deak <imre.deak@intel.com> Reviewed-by: David Weinehall <david.weinehall@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1454071949-24677-1-git-send-email-imre.deak@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/intel_dp.c')
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index f44aba1..a073f04 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -979,7 +979,10 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
if (WARN_ON(txsize > 20))
return -E2BIG;
- memcpy(txbuf + HEADER_SIZE, msg->buffer, msg->size);
+ if (msg->buffer)
+ memcpy(txbuf + HEADER_SIZE, msg->buffer, msg->size);
+ else
+ WARN_ON(msg->size);
ret = intel_dp_aux_ch(intel_dp, txbuf, txsize, rxbuf, rxsize);
if (ret > 0) {
OpenPOWER on IntegriCloud