Bug Summary

File:dev/pci/if_xl_pci.c
Warning:line 286, column 4
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 if_xl_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/if_xl_pci.c
1/* $OpenBSD: if_xl_pci.c,v 1.46 2015/11/24 17:11:40 mpi Exp $ */
2
3/*
4 * Copyright (c) 1997, 1998, 1999
5 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Bill Paul.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 * $FreeBSD: if_xl.c,v 1.72 2000/01/09 21:12:59 wpaul Exp $
35 */
36
37#include "bpfilter.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/mbuf.h>
42#include <sys/protosw.h>
43#include <sys/socket.h>
44#include <sys/ioctl.h>
45#include <sys/errno.h>
46#include <sys/malloc.h>
47#include <sys/kernel.h>
48#include <sys/device.h>
49
50#include <net/if.h>
51#include <net/if_media.h>
52
53#include <netinet/in.h>
54#include <netinet/if_ether.h>
55
56#include <dev/mii/miivar.h>
57#include <dev/pci/pcireg.h>
58#include <dev/pci/pcivar.h>
59#include <dev/pci/pcidevs.h>
60
61#if NBPFILTER1 > 0
62#include <net/bpf.h>
63#endif
64
65/*
66 * The following #define causes the code to use PIO to access the
67 * chip's registers instead of memory mapped mode. The reason PIO mode
68 * is on by default is that the Etherlink XL manual seems to indicate
69 * that only the newer revision chips (3c905B) support both PIO and
70 * memory mapped access. Since we want to be compatible with the older
71 * bus master chips, we use PIO here. If you comment this out, the
72 * driver will use memory mapped I/O, which may be faster but which
73 * might not work on some devices.
74 */
75#define XL_USEIOSPACE
76
77#define XL_PCI_FUNCMEM0x0018 0x0018
78#define XL_PCI_INTR0x0004 0x0004
79#define XL_PCI_INTRACK0x8000 0x8000
80
81#include <dev/ic/xlreg.h>
82
83int xl_pci_match(struct device *, void *, void *);
84void xl_pci_attach(struct device *, struct device *, void *);
85int xl_pci_detach(struct device *, int);
86void xl_pci_intr_ack(struct xl_softc *);
87#ifndef SMALL_KERNEL
88void xl_pci_wol_power(void *);
89#endif
90
91struct xl_pci_softc {
92 struct xl_softc psc_softc;
93 pci_chipset_tag_t psc_pc;
94 pcitag_t psc_tag;
95 bus_size_t psc_iosize;
96 bus_size_t psc_funsize;
97};
98
99struct cfattach xl_pci_ca = {
100 sizeof(struct xl_pci_softc), xl_pci_match, xl_pci_attach,
101 xl_pci_detach, xl_activate
102};
103
104const struct pci_matchid xl_pci_devices[] = {
105 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3CSOHO100TX0x7646 },
106 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C900TPO0x9000 },
107 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C900COMBO0x9001 },
108 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C900B0x9004 },
109 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C900BCOMBO0x9005 },
110 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C900BTPC0x9006 },
111 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C900BFL0x900a },
112 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C905TX0x9050 },
113 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C905T40x9051 },
114 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C905BTX0x9055 },
115 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C905BT40x9056 },
116 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C905BCOMBO0x9058 },
117 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C905BFX0x905a },
118 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C980TX0x9800 },
119 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C980CTX0x9805 },
120 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C905CTX0x9200 },
121 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C4500x4500 },
122 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C5550x5055 },
123 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C5560x6055 },
124 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C556B0x6056 },
125 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C92010x9201 },
126 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C920BEMBW0x9202 },
127 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3C5750x5057 },
128 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3CCFE575BT0x5157 },
129 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3CCFE575CT0x5257 },
130 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3CCFEM6560x6560 },
131 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3CCFEM656B0x6562 },
132 { PCI_VENDOR_3COM0x10b7, PCI_PRODUCT_3COM_3CCFEM656C0x6564 },
133};
134
135int
136xl_pci_match(struct device *parent, void *match, void *aux)
137{
138 return (pci_matchbyid((struct pci_attach_args *)aux, xl_pci_devices,
139 nitems(xl_pci_devices)(sizeof((xl_pci_devices)) / sizeof((xl_pci_devices)[0]))));
140}
141
142void
143xl_pci_attach(struct device *parent, struct device *self, void *aux)
144{
145 struct xl_pci_softc *psc = (void *)self;
146 struct xl_softc *sc = &psc->psc_softc;
147 struct pci_attach_args *pa = aux;
148 pci_chipset_tag_t pc = pa->pa_pc;
149 pci_intr_handle_t ih;
150 const char *intrstr = NULL((void *)0);
151 bus_size_t iosize, funsize;
1
'funsize' declared without an initial value
152#ifndef SMALL_KERNEL
153 u_int32_t command;
154#endif
155
156 psc->psc_pc = pc;
157 psc->psc_tag = pa->pa_tag;
158 sc->sc_dmat = pa->pa_dmat;
159
160 sc->xl_flags = 0;
161 sc->wol_power = sc->wol_power_arg = NULL((void *)0);
162
163 /* set required flags */
164 switch (PCI_PRODUCT(pa->pa_id)(((pa->pa_id) >> 16) & 0xffff)) {
2
Control jumps to the 'default' case at line 217
165 case TC_DEVICEID_HURRICANE_5550x5055:
166 sc->xl_flags |= XL_FLAG_EEPROM_OFFSET_300x0004 | XL_FLAG_8BITROM0x0010;
167 break;
168 case TC_DEVICEID_HURRICANE_5560x6055:
169 sc->xl_flags |= XL_FLAG_FUNCREG0x0001 | XL_FLAG_PHYOK0x0002 |
170 XL_FLAG_EEPROM_OFFSET_300x0004 | XL_FLAG_WEIRDRESET0x0008;
171 sc->xl_flags |= XL_FLAG_INVERT_LED_PWR0x0020|XL_FLAG_INVERT_MII_PWR0x0040;
172 sc->xl_flags |= XL_FLAG_8BITROM0x0010;
173 break;
174 case TC_DEVICEID_HURRICANE_556B0x6056:
175 sc->xl_flags |= XL_FLAG_FUNCREG0x0001 | XL_FLAG_PHYOK0x0002 |
176 XL_FLAG_EEPROM_OFFSET_300x0004 | XL_FLAG_WEIRDRESET0x0008;
177 sc->xl_flags |= XL_FLAG_INVERT_LED_PWR0x0020|XL_FLAG_INVERT_MII_PWR0x0040;
178 break;
179 case PCI_PRODUCT_3COM_3C92010x9201:
180 case PCI_PRODUCT_3COM_3C920BEMBW0x9202:
181 sc->xl_flags |= XL_FLAG_PHYOK0x0002;
182 break;
183 case TC_DEVICEID_BOOMERANG_10_100BT0x9050:
184 sc->xl_flags |= XL_FLAG_NO_MMIO0x0200;
185 break;
186 case PCI_PRODUCT_3COM_3C5750x5057:
187 sc->xl_flags |= XL_FLAG_PHYOK0x0002 | XL_FLAG_EEPROM_OFFSET_300x0004 |
188 XL_FLAG_8BITROM0x0010;
189 break;
190 case PCI_PRODUCT_3COM_3CCFE575BT0x5157:
191 sc->xl_flags = XL_FLAG_PHYOK0x0002 | XL_FLAG_EEPROM_OFFSET_300x0004 |
192 XL_FLAG_8BITROM0x0010 | XL_FLAG_INVERT_LED_PWR0x0020;
193 sc->xl_flags |= XL_FLAG_FUNCREG0x0001;
194 break;
195 case PCI_PRODUCT_3COM_3CCFE575CT0x5257:
196 sc->xl_flags = XL_FLAG_PHYOK0x0002 | XL_FLAG_EEPROM_OFFSET_300x0004 |
197 XL_FLAG_8BITROM0x0010 | XL_FLAG_INVERT_MII_PWR0x0040;
198 sc->xl_flags |= XL_FLAG_FUNCREG0x0001;
199 break;
200 case PCI_PRODUCT_3COM_3CCFEM6560x6560:
201 sc->xl_flags = XL_FLAG_PHYOK0x0002 | XL_FLAG_EEPROM_OFFSET_300x0004 |
202 XL_FLAG_8BITROM0x0010 | XL_FLAG_INVERT_LED_PWR0x0020 |
203 XL_FLAG_INVERT_MII_PWR0x0040;
204 sc->xl_flags |= XL_FLAG_FUNCREG0x0001;
205 break;
206 case PCI_PRODUCT_3COM_3CCFEM656B0x6562:
207 sc->xl_flags = XL_FLAG_PHYOK0x0002 | XL_FLAG_EEPROM_OFFSET_300x0004 |
208 XL_FLAG_8BITROM0x0010 | XL_FLAG_INVERT_LED_PWR0x0020 |
209 XL_FLAG_INVERT_MII_PWR0x0040;
210 sc->xl_flags |= XL_FLAG_FUNCREG0x0001;
211 break;
212 case PCI_PRODUCT_3COM_3CCFEM656C0x6564:
213 sc->xl_flags = XL_FLAG_PHYOK0x0002 | XL_FLAG_EEPROM_OFFSET_300x0004 |
214 XL_FLAG_8BITROM0x0010 | XL_FLAG_INVERT_MII_PWR0x0040;
215 sc->xl_flags |= XL_FLAG_FUNCREG0x0001;
216 break;
217 default:
218 break;
3
Execution continues on line 221
219 }
220
221 pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D00x0000);
222
223#ifndef SMALL_KERNEL
224 /*
225 * The card is WOL-capable if it supports PME# assertion
226 * from D3hot power state. Install a callback to configure
227 * PCI power state for WOL. It will be invoked when the
228 * interface stops and WOL was enabled.
229 */
230 command = pci_conf_read(pc, pa->pa_tag, XL_PCI_CAPID0xDC);
231 if ((command >> 16) & XL_PME_CAP_D3_HOT0x4000) {
4
Assuming the condition is false
5
Taking false branch
232 sc->wol_power = xl_pci_wol_power;
233 sc->wol_power_arg = psc;
234 }
235#endif
236
237 /*
238 * Map control/status registers.
239 */
240#ifdef XL_USEIOSPACE
241 if (pci_mapreg_map(pa, XL_PCI_LOIO0x10, PCI_MAPREG_TYPE_IO0x00000001, 0,
6
Assuming the condition is false
7
Taking false branch
242 &sc->xl_btag, &sc->xl_bhandle, NULL((void *)0), &iosize, 0)) {
243 printf(": can't map i/o space\n");
244 return;
245 }
246#else
247 if (pci_mapreg_map(pa, XL_PCI_LOMEM0x14, PCI_MAPREG_TYPE_MEM0x00000000, 0,
248 &sc->xl_btag, &sc->xl_bhandle, NULL((void *)0), &iosize, 0)) {
249 printf(": can't map i/o space\n");
250 return;
251 }
252#endif
253 psc->psc_iosize = iosize;
254
255 if (sc->xl_flags & XL_FLAG_FUNCREG0x0001) {
8
Assuming the condition is false
9
Taking false branch
256 if (pci_mapreg_map(pa, XL_PCI_FUNCMEM0x0018, PCI_MAPREG_TYPE_MEM0x00000000, 0,
257 &sc->xl_funct, &sc->xl_funch, NULL((void *)0), &funsize, 0)) {
258 printf(": can't map i/o space\n");
259 bus_space_unmap(sc->xl_btag, sc->xl_bhandle, iosize);
260 return;
261 }
262 psc->psc_funsize = funsize;
263 sc->intr_ack = xl_pci_intr_ack;
264 }
265
266 /*
267 * Allocate our interrupt.
268 */
269 if (pci_intr_map(pa, &ih)) {
10
Assuming the condition is false
11
Taking false branch
270 printf(": couldn't map interrupt\n");
271 bus_space_unmap(sc->xl_btag, sc->xl_bhandle, iosize);
272 if (sc->xl_flags & XL_FLAG_FUNCREG0x0001)
273 bus_space_unmap(sc->xl_funct, sc->xl_funch, funsize);
274 return;
275 }
276
277 intrstr = pci_intr_string(pc, ih);
278 sc->xl_intrhand = pci_intr_establish(pc, ih, IPL_NET0x7, xl_intr, sc,
279 self->dv_xname);
280 if (sc->xl_intrhand == NULL((void *)0)) {
12
Assuming field 'xl_intrhand' is equal to NULL
13
Taking true branch
281 printf(": couldn't establish interrupt");
282 if (intrstr != NULL((void *)0))
14
Assuming 'intrstr' is equal to NULL
15
Taking false branch
283 printf(" at %s", intrstr);
284 bus_space_unmap(sc->xl_btag, sc->xl_bhandle, iosize);
285 if (sc->xl_flags & XL_FLAG_FUNCREG0x0001)
16
Assuming the condition is true
17
Taking true branch
286 bus_space_unmap(sc->xl_funct, sc->xl_funch, funsize);
18
3rd function call argument is an uninitialized value
287 return;
288 }
289 printf(": %s", intrstr);
290
291 xl_attach(sc);
292}
293
294int
295xl_pci_detach(struct device *self, int flags)
296{
297 struct xl_pci_softc *psc = (void *)self;
298 struct xl_softc *sc = &psc->psc_softc;
299
300 if (sc->xl_intrhand != NULL((void *)0)) {
301 pci_intr_disestablish(psc->psc_pc, sc->xl_intrhand);
302 xl_detach(sc);
303 }
304 if (psc->psc_iosize > 0)
305 bus_space_unmap(sc->xl_btag, sc->xl_bhandle, psc->psc_iosize);
306 if (psc->psc_funsize > 0)
307 bus_space_unmap(sc->xl_funct, sc->xl_funch, psc->psc_funsize);
308 return (0);
309}
310
311void
312xl_pci_intr_ack(struct xl_softc *sc)
313{
314 bus_space_write_4(sc->xl_funct, sc->xl_funch, XL_PCI_INTR,((sc->xl_funct)->write_4((sc->xl_funch), (0x0004), (
0x8000)))
315 XL_PCI_INTRACK)((sc->xl_funct)->write_4((sc->xl_funch), (0x0004), (
0x8000)))
;
316}
317
318#ifndef SMALL_KERNEL
319void
320xl_pci_wol_power(void *ppsc)
321{
322 struct xl_pci_softc *psc = (struct xl_pci_softc*)ppsc;
323 u_int32_t command;
324
325 /* Make sure wake-up generation is enabled. */
326 command = pci_conf_read(psc->psc_pc, psc->psc_tag, XL_PCI_PWRMGMTCTRL0xE0);
327 command |= XL_PME_EN0x0100;
328 pci_conf_write(psc->psc_pc, psc->psc_tag, XL_PCI_PWRMGMTCTRL0xE0, command);
329}
330#endif