Commit 527d0e5
committed
usb: phytium_v2: fix uninitialized phytium_usb in phytium_pci_probe
Log:
drivers/usb/phytium_usb_v2/pci.c:33:6: error: variable 'phytium_usb' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
33 | if (pci_is_enabled(pdev)) {
| ^~~~~~~~~~~~~~~~~~~~
drivers/usb/phytium_usb_v2/pci.c:45:2: note: uninitialized use occurs here
45 | phytium_usb->otg_res.start = pci_resource_start(pdev, 0);
| ^~~~~~~~~~~
drivers/usb/phytium_usb_v2/pci.c:33:2: note: remove the 'if' if its condition is always true
33 | if (pci_is_enabled(pdev)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/phytium_usb_v2/pci.c:24:33: note: initialize the variable 'phytium_usb' to silence this warning
24 | struct phytium_usb *phytium_usb;
| ^
| = NULL
1 error generated.
similar to the following logic:
pci_set_master(pdev);
if (pci_is_enabled(func)) {
cdnsp = pci_get_drvdata(func);
} else {
cdnsp = kzalloc(sizeof(*cdnsp), GFP_KERNEL);
if (!cdnsp) {
ret = -ENOMEM;
goto disable_pci;
}
}
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>1 parent 6022a9f commit 527d0e5
1 file changed
Lines changed: 7 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
0 commit comments