NetBSD-Bugs archive

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

port-amd64/51864: unreachable code in ichlpcib



>Number:         51864
>Category:       port-amd64
>Synopsis:       unreachable code in ichlpcib
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-amd64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 13 13:55:00 +0000 2017
>Originator:     coypu
>Release:        NetBSD 7.99.58
>Organization:
>Environment:
NetBSD box 7.99.58 NetBSD 7.99.58 (GENERIC) #0: Thu Jan 12 13:45:00 IST 2017  fly@box:/usr/amd64/sys/arch/amd64/compile/GENERIC amd64

>Description:
LPCIB_ICH5_HPTC_WIN_MASK is a problematic choice of mask.

from sys/dev/ic/i82801lpcreg.h:

 84 #define LPCIB_ICH5_HPTC_WIN_MASK        0x0000c000                       
 85 #define LPCIB_ICH5_HPTC_0000            0x00000000
 86 #define LPCIB_ICH5_HPTC_0000_BASE       0xfed00000
 87 #define LPCIB_ICH5_HPTC_1000            0x00008000
 88 #define LPCIB_ICH5_HPTC_1000_BASE       0xfed01000
 89 #define LPCIB_ICH5_HPTC_2000            0x00010000
 90 #define LPCIB_ICH5_HPTC_2000_BASE       0xfed02000
 91 #define LPCIB_ICH5_HPTC_3000            0x00018000
 92 #define LPCIB_ICH5_HPTC_3000_BASE       0xfed03000

That means the following code in sys/arch/x86/pci/ichlpcib.c:

 823                 switch (val & LPCIB_ICH5_HPTC_WIN_MASK) {
 824                 case LPCIB_ICH5_HPTC_0000:
 825                         hpet_reg = LPCIB_ICH5_HPTC_0000_BASE;
 826                         break;
 827                 case LPCIB_ICH5_HPTC_1000:
 828                         hpet_reg = LPCIB_ICH5_HPTC_1000_BASE;
 829                         break;
 830                 case LPCIB_ICH5_HPTC_2000:
 831                         hpet_reg = LPCIB_ICH5_HPTC_2000_BASE;
 832                         break;
 833                 case LPCIB_ICH5_HPTC_3000:
 834                         hpet_reg = LPCIB_ICH5_HPTC_3000_BASE;
 835                         break;

val & LPCIB_ICH5_HPTC_WIN_MASK == LPCIB_ICH5_HPTC_3000
val & 0xc000 == 0x18000

will never happen, and it will end up in the default case.

(spotted by coverity, CID 980234)
>How-To-Repeat:

>Fix:



Home | Main Index | Thread Index | Old Index