Bug Summary

File:dev/pci/cy_pci.c
Warning:line 121, column 6
3rd function call argument is an uninitialized value

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name cy_pci.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -ffreestanding -mcmodel=kernel -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -target-feature -sse2 -target-feature -sse -target-feature -3dnow -target-feature -mmx -target-feature +save-args -disable-red-zone -no-implicit-float -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -nostdsysteminc -nobuiltininc -resource-dir /usr/local/lib/clang/13.0.0 -I /usr/src/sys -I /usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -I /usr/src/sys/arch -I /usr/src/sys/dev/pci/drm/include -I /usr/src/sys/dev/pci/drm/include/uapi -I /usr/src/sys/dev/pci/drm/amd/include/asic_reg -I /usr/src/sys/dev/pci/drm/amd/include -I /usr/src/sys/dev/pci/drm/amd/amdgpu -I /usr/src/sys/dev/pci/drm/amd/display -I /usr/src/sys/dev/pci/drm/amd/display/include -I /usr/src/sys/dev/pci/drm/amd/display/dc -I /usr/src/sys/dev/pci/drm/amd/display/amdgpu_dm -I /usr/src/sys/dev/pci/drm/amd/pm/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu11 -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu12 -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/hwmgr -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/smumgr -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc/hw -I /usr/src/sys/dev/pci/drm/amd/display/dc/clk_mgr -I /usr/src/sys/dev/pci/drm/amd/display/modules/inc -I /usr/src/sys/dev/pci/drm/amd/display/modules/hdcp -I /usr/src/sys/dev/pci/drm/amd/display/dmub/inc -I /usr/src/sys/dev/pci/drm/i915 -D DDB -D DIAGNOSTIC -D KTRACE -D ACCOUNTING -D KMEMSTATS -D PTRACE -D POOL_DEBUG -D CRYPTO -D SYSVMSG -D SYSVSEM -D SYSVSHM -D UVM_SWAP_ENCRYPT -D FFS -D FFS2 -D FFS_SOFTUPDATES -D UFS_DIRHASH -D QUOTA -D EXT2FS -D MFS -D NFSCLIENT -D NFSSERVER -D CD9660 -D UDF -D MSDOSFS -D FIFO -D FUSE -D SOCKET_SPLICE -D TCP_ECN -D TCP_SIGNATURE -D INET6 -D IPSEC -D PPP_BSDCOMP -D PPP_DEFLATE -D PIPEX -D MROUTING -D MPLS -D BOOT_CONFIG -D USER_PCICONF -D APERTURE -D MTRR -D NTFS -D HIBERNATE -D PCIVERBOSE -D USBVERBOSE -D WSDISPLAY_COMPAT_USL -D WSDISPLAY_COMPAT_RAWKBD -D WSDISPLAY_DEFAULTSCREENS=6 -D X86EMU -D ONEWIREVERBOSE -D MULTIPROCESSOR -D MAXUSERS=80 -D _KERNEL -D CONFIG_DRM_AMD_DC_DCN3_0 -O2 -Wno-pointer-sign -Wno-address-of-packed-member -Wno-constant-conversion -Wno-unused-but-set-variable -Wno-gnu-folding-constant -fdebug-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -o /usr/obj/sys/arch/amd64/compile/GENERIC.MP/scan-build/2022-01-12-131800-47421-1 -x c /usr/src/sys/dev/pci/cy_pci.c
1/* $OpenBSD: cy_pci.c,v 1.15 2021/03/05 12:40:13 jsg Exp $ */
2/*
3 * Copyright (c) 1996 Timo Rossi.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the author nor the names of contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31/*
32 * cy_pci.c
33 *
34 * Driver for Cyclades Cyclom-8/16/32 multiport serial cards
35 * (currently not tested with Cyclom-32 cards)
36 *
37 * Timo Rossi, 1996
38 */
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/device.h>
43
44#include <machine/bus.h>
45
46#include <dev/pci/pcivar.h>
47#include <dev/pci/pcireg.h>
48#include <dev/pci/pcidevs.h>
49
50#include <dev/ic/cd1400reg.h>
51#include <dev/ic/cyreg.h>
52
53int cy_pci_match(struct device *, void *, void *);
54void cy_pci_attach(struct device *, struct device *, void *);
55
56struct cy_pci_softc {
57 struct cy_softc sc_cy; /* real softc */
58
59 bus_space_tag_t sc_iot; /* PLX i/o tag */
60 bus_space_handle_t sc_ioh; /* PLX i/o handle */
61};
62
63struct cfattach cy_pci_ca = {
64 sizeof(struct cy_pci_softc), cy_pci_match, cy_pci_attach
65};
66
67#define CY_PLX_9050_ICS_IENABLE0x040 0x040
68#define CY_PLX_9050_ICS_LOCAL_IENABLE0x001 0x001
69#define CY_PLX_9050_ICS_LOCAL_IPOLARITY0x002 0x002
70#define CY_PLX_9060_ICS_IENABLE0x100 0x100
71#define CY_PLX_9060_ICS_LOCAL_IENABLE0x800 0x800
72
73const struct pci_matchid cy_pci_devices[] = {
74 { PCI_VENDOR_CYCLADES0x120e, PCI_PRODUCT_CYCLADES_CYCLOMY_10x0100 },
75 { PCI_VENDOR_CYCLADES0x120e, PCI_PRODUCT_CYCLADES_CYCLOMY_20x0101 },
76 { PCI_VENDOR_CYCLADES0x120e, PCI_PRODUCT_CYCLADES_CYCLOM4Y_10x0102 },
77 { PCI_VENDOR_CYCLADES0x120e, PCI_PRODUCT_CYCLADES_CYCLOM4Y_20x0103 },
78 { PCI_VENDOR_CYCLADES0x120e, PCI_PRODUCT_CYCLADES_CYCLOM8Y_10x0104 },
79 { PCI_VENDOR_CYCLADES0x120e, PCI_PRODUCT_CYCLADES_CYCLOM8Y_20x0105 },
80};
81
82int
83cy_pci_match(struct device *parent, void *match, void *aux)
84{
85 return (pci_matchbyid((struct pci_attach_args *)aux, cy_pci_devices,
86 nitems(cy_pci_devices)(sizeof((cy_pci_devices)) / sizeof((cy_pci_devices)[0]))));
87}
88
89void
90cy_pci_attach(struct device *parent, struct device *self, void *aux)
91{
92 struct cy_pci_softc *psc = (struct cy_pci_softc *)self;
93 struct cy_softc *sc = (struct cy_softc *)self;
94 struct pci_attach_args *pa = aux;
95 const char *intrstr = NULL((void *)0);
96 pci_intr_handle_t ih;
97 pcireg_t memtype;
1
'memtype' declared without an initial value
98 int plx_ver;
99
100 sc->sc_bustype = CY_BUSTYPE_PCI1;
101
102 switch (PCI_PRODUCT(pa->pa_id)(((pa->pa_id) >> 16) & 0xffff)) {
2
'Default' branch taken. Execution continues on line 115
103 case PCI_PRODUCT_CYCLADES_CYCLOMY_10x0100:
104 case PCI_PRODUCT_CYCLADES_CYCLOM4Y_10x0102:
105 case PCI_PRODUCT_CYCLADES_CYCLOM8Y_10x0104:
106 memtype = PCI_MAPREG_TYPE_MEM0x00000000|PCI_MAPREG_MEM_TYPE_32BIT_1M0x00000002;
107 break;
108 case PCI_PRODUCT_CYCLADES_CYCLOMY_20x0101:
109 case PCI_PRODUCT_CYCLADES_CYCLOM4Y_20x0103:
110 case PCI_PRODUCT_CYCLADES_CYCLOM8Y_20x0105:
111 memtype = PCI_MAPREG_TYPE_MEM0x00000000|PCI_MAPREG_MEM_TYPE_32BIT0x00000000;
112 break;
113 }
114
115 if (pci_mapreg_map(pa, 0x14, PCI_MAPREG_TYPE_IO0x00000001, 0,
3
Assuming the condition is false
4
Taking false branch
116 &psc->sc_iot, &psc->sc_ioh, NULL((void *)0), NULL((void *)0), 0) != 0) {
117 printf(": unable to map PLX registers\n");
118 return;
119 }
120
121 if (pci_mapreg_map(pa, 0x18, memtype, 0, &sc->sc_memt,
5
3rd function call argument is an uninitialized value
122 &sc->sc_memh, NULL((void *)0), NULL((void *)0), 0) != 0) {
123 printf(": couldn't map device registers\n");
124 return;
125 }
126
127 if ((sc->sc_nr_cd1400s = cy_probe_common(sc->sc_memt, sc->sc_memh,
128 CY_BUSTYPE_PCI1)) == 0) {
129 printf(": PCI Cyclom card with no CD1400s\n");
130 return;
131 }
132
133 if (pci_intr_map(pa, &ih) != 0) {
134 printf(": couldn't map interrupt\n");
135 return;
136 }
137
138 intrstr = pci_intr_string(pa->pa_pc, ih);
139 sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_TTY0x9, cy_intr,
140 sc, sc->sc_dev.dv_xname);
141 if (sc->sc_ih == NULL((void *)0)) {
142 printf(": couldn't establish interrupt");
143 if (intrstr != NULL((void *)0))
144 printf(" at %s", intrstr);
145 printf("\n");
146 return;
147 }
148 printf(": %s", intrstr);
149
150 cy_attach(parent, self);
151
152 /* Get PLX version */
153 plx_ver = bus_space_read_1(sc->sc_memt, sc->sc_memh, CY_PLX_VER)((sc->sc_memt)->read_1((sc->sc_memh), (0x3400))) & 0x0f;
154
155 /* Enable PCI card interrupts */
156 switch (plx_ver) {
157 case CY_PLX_90500x0b:
158 bus_space_write_2(psc->sc_iot, psc->sc_ioh, CY_PCI_INTENA_9050,((psc->sc_iot)->write_2((psc->sc_ioh), (0x4c), (0x040
| 0x001 | 0x002)))
159 CY_PLX_9050_ICS_IENABLE | CY_PLX_9050_ICS_LOCAL_IENABLE |((psc->sc_iot)->write_2((psc->sc_ioh), (0x4c), (0x040
| 0x001 | 0x002)))
160 CY_PLX_9050_ICS_LOCAL_IPOLARITY)((psc->sc_iot)->write_2((psc->sc_ioh), (0x4c), (0x040
| 0x001 | 0x002)))
;
161 break;
162
163 case CY_PLX_90600x0c:
164 case CY_PLX_90800x0d:
165 default:
166 bus_space_write_2(psc->sc_iot, psc->sc_ioh, CY_PCI_INTENA,((psc->sc_iot)->write_2((psc->sc_ioh), (0x68), (((psc
->sc_iot)->read_2((psc->sc_ioh), (0x68))) | 0x100 | 0x800
)))
167 bus_space_read_2(psc->sc_iot, psc->sc_ioh,((psc->sc_iot)->write_2((psc->sc_ioh), (0x68), (((psc
->sc_iot)->read_2((psc->sc_ioh), (0x68))) | 0x100 | 0x800
)))
168 CY_PCI_INTENA) | CY_PLX_9060_ICS_IENABLE |((psc->sc_iot)->write_2((psc->sc_ioh), (0x68), (((psc
->sc_iot)->read_2((psc->sc_ioh), (0x68))) | 0x100 | 0x800
)))
169 CY_PLX_9060_ICS_LOCAL_IENABLE)((psc->sc_iot)->write_2((psc->sc_ioh), (0x68), (((psc
->sc_iot)->read_2((psc->sc_ioh), (0x68))) | 0x100 | 0x800
)))
;
170 }
171}