Module Name: src
Committed By: msaitoh
Date: Tue Jan 7 13:51:38 UTC 2020
Modified Files:
src/sys/external/bsd/drm2/dist/drm/radeon: radeon_atombios_dp.c
Log Message:
Don't call memcpy() when the length is 0 (and the source pointer is NULL)
in radeon_dp_aux_transfer_atom() to avoid undefined behavior. Found by kUBSan.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c
diff -u src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c:1.1 src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c:1.2
--- src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c:1.1 Mon Aug 27 14:38:20 2018
+++ src/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c Tue Jan 7 13:51:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: radeon_atombios_dp.c,v 1.1 2018/08/27 14:38:20 riastradh Exp $ */
+/* $NetBSD: radeon_atombios_dp.c,v 1.2 2020/01/07 13:51:38 msaitoh Exp $ */
/*
* Copyright 2007-8 Advanced Micro Devices, Inc.
@@ -27,7 +27,7 @@
* Jerome Glisse
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeon_atombios_dp.c,v 1.1 2018/08/27 14:38:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_atombios_dp.c,v 1.2 2020/01/07 13:51:38 msaitoh Exp $");
#include <drm/drmP.h>
#include <drm/radeon_drm.h>
@@ -196,9 +196,10 @@ radeon_dp_aux_transfer_atom(struct drm_d
tx_size = HEADER_SIZE + msg->size;
if (msg->size == 0)
tx_buf[3] |= BARE_ADDRESS_SIZE << 4;
- else
+ else {
tx_buf[3] |= tx_size << 4;
- memcpy(tx_buf + HEADER_SIZE, msg->buffer, msg->size);
+ memcpy(tx_buf + HEADER_SIZE, msg->buffer, msg->size);
+ }
ret = radeon_process_aux_ch(chan,
tx_buf, tx_size, NULL, 0, delay, &ack);
if (ret >= 0)