Skip to content

Commit

Permalink
PCI: vmd: Fix uninitialized variable usage in vmd_enable_domain()
Browse files Browse the repository at this point in the history
[ Upstream commit 0c0206d ]

The ret variable in the vmd_enable_domain() function was used
uninitialized when printing a warning message upon failure of
the pci_reset_bus() function.

Thus, fix the issue by assigning ret with the value returned from
pci_reset_bus() before referencing it in the warning message.

This was detected by Smatch:

  drivers/pci/controller/vmd.c:931 vmd_enable_domain() error: uninitialized symbol 'ret'.

[kwilczynski: drop the second patch from the series, add missing reported
by tag, commit log]
Fixes: 0a58465 ("PCI: vmd: Fix secondary bus reset for Intel bridges")
Link: https://lore.kernel.org/all/[email protected]
Link: https://lore.kernel.org/linux-pci/[email protected]
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Xinghui Li <[email protected]>
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Reviewed-by: Nirmal Patel <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Xinghui Li authored and gregkh committed Jul 19, 2023
1 parent d66a530 commit d1a2164
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/pci/controller/vmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,8 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
if (!list_empty(&child->devices)) {
dev = list_first_entry(&child->devices,
struct pci_dev, bus_list);
if (pci_reset_bus(dev))
ret = pci_reset_bus(dev);
if (ret)
pci_warn(dev, "can't reset device: %d\n", ret);

break;
Expand Down

0 comments on commit d1a2164

Please sign in to comment.