Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/dist/drm/radeon Don't call memcpy() wh...



details:   https://anonhg.NetBSD.org/src/rev/7154185f82f8
branches:  trunk
changeset: 847862:7154185f82f8
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Jan 07 13:51:38 2020 +0000

description:
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.

diffstat:

 sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r 8f5d360a7a3d -r 7154185f82f8 sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c
--- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c        Tue Jan 07 13:48:01 2020 +0000
+++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_atombios_dp.c        Tue Jan 07 13:51:38 2020 +0000
@@ -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 @@
                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)



Home | Main Index | Thread Index | Old Index