clang -cc1 -cc1 -triple amd64-unknown-openbsd7.4 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cardbus_map.c -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 -ffp-contract=on -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 -target-feature +retpoline-external-thunk -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/llvm16/lib/clang/16 -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/legacy-dpm -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc -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/swsmu/smu13 -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/inc -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/pm/swsmu/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc/pmfw_if -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 SUSPEND -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 -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 -fcf-protection=branch -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 /home/ben/Projects/scan/2024-01-11-110808-61670-1 -x c /usr/src/sys/dev/cardbus/cardbus_map.c
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | #include <sys/param.h> |
33 | #include <sys/systm.h> |
34 | |
35 | #include <machine/bus.h> |
36 | |
37 | #include <dev/cardbus/cardbusvar.h> |
38 | |
39 | #include <dev/pci/pcireg.h> /* XXX */ |
40 | |
41 | #if defined DEBUG && !defined CARDBUS_MAP_DEBUG |
42 | #define CARDBUS_MAP_DEBUG |
43 | #endif |
44 | |
45 | #if defined CARDBUS_MAP_DEBUG |
46 | #define STATIC |
47 | #define DPRINTF(a) printf a |
48 | #else |
49 | #ifdef DDB |
50 | #define STATIC |
51 | #else |
52 | #define STATIC static |
53 | #endif |
54 | #define DPRINTF(a) |
55 | #endif |
56 | |
57 | |
58 | |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | |
65 | |
66 | |
67 | int |
68 | cardbus_mapreg_map(struct cardbus_softc *sc, int func, int reg, |
69 | pcireg_t type, int busflags, bus_space_tag_t *tagp, |
70 | bus_space_handle_t *handlep, bus_addr_t *basep, bus_size_t *sizep) |
71 | { |
72 | cardbus_chipset_tag_t cc = sc->sc_cc; |
73 | pci_chipset_tag_t pc = sc->sc_pc; |
74 | cardbus_function_tag_t cf = sc->sc_cf; |
75 | bus_space_tag_t bustag; |
76 | rbus_tag_t rbustag; |
77 | bus_space_handle_t handle; |
| 1 | 'handle' declared without an initial value | |
|
78 | bus_addr_t base; |
79 | bus_size_t size; |
80 | int flags; |
81 | int status = 0; |
82 | |
83 | pcitag_t tag = pci_make_tag(pc, sc->sc_bus, |
84 | sc->sc_device, func); |
85 | |
86 | DPRINTF(("cardbus_mapreg_map called: %s %x\n", sc->sc_dev.dv_xname, |
87 | type)); |
88 | |
89 | if (pci_mapreg_info(pc, tag, reg, type, &base, &size, &flags)) |
| 2 | | Assuming the condition is true | |
|
| |
90 | status = 1; |
91 | |
92 | if (PCI_MAPREG_TYPE(type) == PCI_MAPREG_TYPE_IO) { |
| 4 | | Assuming the condition is false | |
|
| |
93 | bustag = sc->sc_iot; |
94 | rbustag = sc->sc_rbus_iot; |
95 | } else { |
96 | bustag = sc->sc_memt; |
97 | rbustag = sc->sc_rbus_memt; |
98 | } |
99 | if (status == 0) { |
| |
100 | bus_addr_t mask = size - 1; |
101 | if (base != 0) |
102 | mask = 0xffffffff; |
103 | if ((*cf->cardbus_space_alloc)(cc, rbustag, base, size, mask, |
104 | size, busflags | flags, &base, &handle)) { |
105 | panic("io alloc"); |
106 | } |
107 | } |
108 | pci_conf_write(pc, tag, reg, base); |
109 | |
110 | DPRINTF(("cardbus_mapreg_map: physaddr %lx\n", (unsigned long)base)); |
111 | |
112 | if (tagp != 0) |
| 7 | | Assuming 'tagp' is equal to null | |
|
| |
113 | *tagp = bustag; |
114 | if (handlep != 0) |
| 9 | | Assuming 'handlep' is not equal to null | |
|
| |
115 | *handlep = handle; |
| 11 | | Assigned value is garbage or undefined |
|
116 | if (basep != 0) |
117 | *basep = base; |
118 | if (sizep != 0) |
119 | *sizep = size; |
120 | |
121 | return (0); |
122 | } |
123 | |
124 | |
125 | |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | |
134 | |
135 | |
136 | |
137 | int |
138 | cardbus_mapreg_unmap(struct cardbus_softc *sc, int func, int reg, |
139 | bus_space_tag_t tag, bus_space_handle_t handle, bus_size_t size) |
140 | { |
141 | cardbus_chipset_tag_t cc = sc->sc_cc; |
142 | pci_chipset_tag_t pc = sc->sc_pc; |
143 | cardbus_function_tag_t cf = sc->sc_cf; |
144 | int st = 1; |
145 | pcitag_t cardbustag; |
146 | rbus_tag_t rbustag; |
147 | |
148 | if (sc->sc_iot == tag) { |
149 | |
150 | DPRINTF(("%s: unmap i/o space\n", sc->sc_dev.dv_xname)); |
151 | rbustag = sc->sc_rbus_iot; |
152 | } else if (sc->sc_memt == tag) { |
153 | |
154 | DPRINTF(("%s: unmap mem space\n", sc->sc_dev.dv_xname)); |
155 | rbustag = sc->sc_rbus_memt; |
156 | } else |
157 | return (1); |
158 | |
159 | cardbustag = pci_make_tag(pc, sc->sc_bus, sc->sc_device, func); |
160 | |
161 | pci_conf_write(pc, cardbustag, reg, 0); |
162 | |
163 | (*cf->cardbus_space_free)(cc, rbustag, handle, size); |
164 | |
165 | return (st); |
166 | } |