Skip to content

Commit 0e61cb3

Browse files
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 0e61cb3

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

  • drivers/usb/phytium_usb_v2

drivers/usb/phytium_usb_v2/pci.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ static int phytium_pci_probe(struct pci_dev *pdev,
3232
pci_set_master(pdev);
3333
if (pci_is_enabled(pdev)) {
3434
phytium_usb = pci_get_drvdata(pdev);
35+
}
36+
37+
if (!phytium_usb) {
38+
phytium_usb = kzalloc(sizeof(*phytium_usb), GFP_KERNEL);
3539
if (!phytium_usb) {
36-
phytium_usb = kzalloc(sizeof(*phytium_usb), GFP_KERNEL);
37-
if (!phytium_usb) {
38-
ret = -ENOMEM;
39-
goto disabled_pci;
40-
}
40+
ret = -ENOMEM;
41+
goto disabled_pci;
4142
}
42-
}
43+
}
4344

4445
//otg resource init
4546
phytium_usb->otg_res.start = pci_resource_start(pdev, 0);

0 commit comments

Comments
 (0)