Sat Jan 25 15:59:11 2020 UTC ()
Fix uninitialized variable. There may not be a TYPE_ASCII block. Found by
kMSan with nouveau.


(maxv)
diff -r1.14 -r1.15 src/sys/dev/videomode/edid.c

cvs diff -r1.14 -r1.15 src/sys/dev/videomode/edid.c (expand / switch to unified diff)

--- src/sys/dev/videomode/edid.c 2018/07/10 01:44:30 1.14
+++ src/sys/dev/videomode/edid.c 2020/01/25 15:59:11 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: edid.c,v 1.14 2018/07/10 01:44:30 macallan Exp $ */ 1/* $NetBSD: edid.c,v 1.15 2020/01/25 15:59:11 maxv Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006 Itronix Inc. 4 * Copyright (c) 2006 Itronix Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Garrett D'Amore for Itronix Inc. 7 * Written by Garrett D'Amore for Itronix Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY 24 * ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */  32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: edid.c,v 1.14 2018/07/10 01:44:30 macallan Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: edid.c,v 1.15 2020/01/25 15:59:11 maxv Exp $");
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/device.h> 39#include <sys/device.h>
40#include <sys/kernel.h> 40#include <sys/kernel.h>
41#include <sys/malloc.h> 41#include <sys/malloc.h>
42#include <dev/videomode/videomode.h> 42#include <dev/videomode/videomode.h>
43#include <dev/videomode/ediddevs.h> 43#include <dev/videomode/ediddevs.h>
44#include <dev/videomode/edidreg.h> 44#include <dev/videomode/edidreg.h>
45#include <dev/videomode/edidvar.h> 45#include <dev/videomode/edidvar.h>
46#include <dev/videomode/vesagtf.h> 46#include <dev/videomode/vesagtf.h>
47 47
48#define EDIDVERBOSE 1 48#define EDIDVERBOSE 1
@@ -457,26 +457,27 @@ edid_block(struct edid_info *edid, uint8 @@ -457,26 +457,27 @@ edid_block(struct edid_info *edid, uint8
457 edid->edid_nmodes++;  457 edid->edid_nmodes++;
458 } 458 }
459 return; 459 return;
460 } 460 }
461 461
462 switch (EDID_BLOCK_TYPE(data)) { 462 switch (EDID_BLOCK_TYPE(data)) {
463 case EDID_DESC_BLOCK_TYPE_SERIAL: 463 case EDID_DESC_BLOCK_TYPE_SERIAL:
464 memcpy(edid->edid_serial, data + EDID_DESC_ASCII_DATA_OFFSET, 464 memcpy(edid->edid_serial, data + EDID_DESC_ASCII_DATA_OFFSET,
465 EDID_DESC_ASCII_DATA_LEN); 465 EDID_DESC_ASCII_DATA_LEN);
466 edid->edid_serial[sizeof(edid->edid_serial) - 1] = 0; 466 edid->edid_serial[sizeof(edid->edid_serial) - 1] = 0;
467 break; 467 break;
468 468
469 case EDID_DESC_BLOCK_TYPE_ASCII: 469 case EDID_DESC_BLOCK_TYPE_ASCII:
 470 memset(edid->edid_comment, 0, sizeof(edid->edid_comment));
470 memcpy(edid->edid_comment, data + EDID_DESC_ASCII_DATA_OFFSET, 471 memcpy(edid->edid_comment, data + EDID_DESC_ASCII_DATA_OFFSET,
471 EDID_DESC_ASCII_DATA_LEN); 472 EDID_DESC_ASCII_DATA_LEN);
472 edid->edid_comment[sizeof(edid->edid_comment) - 1] = 0; 473 edid->edid_comment[sizeof(edid->edid_comment) - 1] = 0;
473 break; 474 break;
474 475
475 case EDID_DESC_BLOCK_TYPE_RANGE: 476 case EDID_DESC_BLOCK_TYPE_RANGE:
476 edid->edid_have_range = 1; 477 edid->edid_have_range = 1;
477 edid->edid_range.er_min_vfreq = EDID_DESC_RANGE_MIN_VFREQ(data); 478 edid->edid_range.er_min_vfreq = EDID_DESC_RANGE_MIN_VFREQ(data);
478 edid->edid_range.er_max_vfreq = EDID_DESC_RANGE_MAX_VFREQ(data); 479 edid->edid_range.er_max_vfreq = EDID_DESC_RANGE_MAX_VFREQ(data);
479 edid->edid_range.er_min_hfreq = EDID_DESC_RANGE_MIN_HFREQ(data); 480 edid->edid_range.er_min_hfreq = EDID_DESC_RANGE_MIN_HFREQ(data);
480 edid->edid_range.er_max_hfreq = EDID_DESC_RANGE_MAX_HFREQ(data); 481 edid->edid_range.er_max_hfreq = EDID_DESC_RANGE_MAX_HFREQ(data);
481 edid->edid_range.er_max_clock = EDID_DESC_RANGE_MAX_CLOCK(data); 482 edid->edid_range.er_max_clock = EDID_DESC_RANGE_MAX_CLOCK(data);
482 if (!EDID_DESC_RANGE_HAVE_GTF2(data)) 483 if (!EDID_DESC_RANGE_HAVE_GTF2(data))
@@ -552,26 +553,28 @@ edid_parse(uint8_t *data, struct edid_in @@ -552,26 +553,28 @@ edid_parse(uint8_t *data, struct edid_in
552 else 553 else
553 edid->edid_vendorname[0] = '\0'; 554 edid->edid_vendorname[0] = '\0';
554 555
555 name = edid_findproduct(edid->edid_vendor, edid->edid_product); 556 name = edid_findproduct(edid->edid_vendor, edid->edid_product);
556 if (name != NULL) 557 if (name != NULL)
557 strlcpy(edid->edid_productname, name, 558 strlcpy(edid->edid_productname, name,
558 sizeof(edid->edid_productname)); 559 sizeof(edid->edid_productname));
559 else 560 else
560 edid->edid_productname[0] = '\0'; 561 edid->edid_productname[0] = '\0';
561 562
562 snprintf(edid->edid_serial, sizeof(edid->edid_serial), "%08x", 563 snprintf(edid->edid_serial, sizeof(edid->edid_serial), "%08x",
563 EDID_SERIAL_NUMBER(data)); 564 EDID_SERIAL_NUMBER(data));
564 565
 566 edid->edid_comment[0] = '\0';
 567
565 edid->edid_week = EDID_WEEK(data); 568 edid->edid_week = EDID_WEEK(data);
566 edid->edid_year = EDID_YEAR(data); 569 edid->edid_year = EDID_YEAR(data);
567 570
568 /* get edid revision */ 571 /* get edid revision */
569 edid->edid_version = EDID_VERSION(data); 572 edid->edid_version = EDID_VERSION(data);
570 edid->edid_revision = EDID_REVISION(data); 573 edid->edid_revision = EDID_REVISION(data);
571 574
572 edid->edid_video_input = EDID_VIDEO_INPUT(data); 575 edid->edid_video_input = EDID_VIDEO_INPUT(data);
573 edid->edid_max_hsize = EDID_MAX_HSIZE(data); 576 edid->edid_max_hsize = EDID_MAX_HSIZE(data);
574 edid->edid_max_vsize = EDID_MAX_VSIZE(data); 577 edid->edid_max_vsize = EDID_MAX_VSIZE(data);
575 578
576 edid->edid_gamma = EDID_GAMMA(data); 579 edid->edid_gamma = EDID_GAMMA(data);
577 edid->edid_features = EDID_FEATURES(data); 580 edid->edid_features = EDID_FEATURES(data);