Skip to content

Commit 8370af2

Browse files
liming011djbw
authored andcommitted
PCI/IDE: Fix off by one error calculating VF RID range
The VF ID range of an SR-IOV device is [0, num_VFs - 1]. pci_ide_stream_alloc() mistakenly uses num_VFs to represent the last ID. Fix that off by one error to stay in bounds of the range. Fixes: 1e4d2ff ("PCI/IDE: Add IDE establishment helpers") Signed-off-by: Li Ming <[email protected]> Reviewed-by: Xu Yilun <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 731bb31 commit 8370af2

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/pci/ide.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ struct pci_ide *pci_ide_stream_alloc(struct pci_dev *pdev)
282282
/* for SR-IOV case, cover all VFs */
283283
num_vf = pci_num_vf(pdev);
284284
if (num_vf)
285-
rid_end = PCI_DEVID(pci_iov_virtfn_bus(pdev, num_vf),
286-
pci_iov_virtfn_devfn(pdev, num_vf));
285+
rid_end = PCI_DEVID(pci_iov_virtfn_bus(pdev, num_vf - 1),
286+
pci_iov_virtfn_devfn(pdev, num_vf - 1));
287287
else
288288
rid_end = pci_dev_id(pdev);
289289

include/linux/pci-ide.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum pci_ide_partner_select {
2626
/**
2727
* struct pci_ide_partner - Per port pair Selective IDE Stream settings
2828
* @rid_start: Partner Port Requester ID range start
29-
* @rid_end: Partner Port Requester ID range end
29+
* @rid_end: Partner Port Requester ID range end (inclusive)
3030
* @stream_index: Selective IDE Stream Register Block selection
3131
* @mem_assoc: PCI bus memory address association for targeting peer partner
3232
* @pref_assoc: PCI bus prefetchable memory address association for

0 commit comments

Comments
 (0)