Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit a84ae28

Browse files
Ryand1234gregkh
authored andcommitted
staging: vme_user: added bound check to geoid
[ Upstream commit a8a8b54 ] The geoid is a module parameter that allows users to hardcode the slot number. A bound check for geoid was added in the probe function because only values between 0 and less than VME_MAX_SLOT are valid. Signed-off-by: Riyan Dhiman <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 5b53a7a commit a84ae28

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

drivers/staging/vme_user/vme_fake.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,12 @@ static int __init fake_init(void)
10641064
struct vme_slave_resource *slave_image;
10651065
struct vme_lm_resource *lm;
10661066

1067+
if (geoid < 0 || geoid >= VME_MAX_SLOTS) {
1068+
pr_err("VME geographical address must be between 0 and %d (exclusive), but got %d\n",
1069+
VME_MAX_SLOTS, geoid);
1070+
return -EINVAL;
1071+
}
1072+
10671073
/* We need a fake parent device */
10681074
vme_root = root_device_register("vme");
10691075
if (IS_ERR(vme_root))

drivers/staging/vme_user/vme_tsi148.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,6 +2252,12 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
22522252
struct vme_dma_resource *dma_ctrlr;
22532253
struct vme_lm_resource *lm;
22542254

2255+
if (geoid < 0 || geoid >= VME_MAX_SLOTS) {
2256+
dev_err(&pdev->dev, "VME geographical address must be between 0 and %d (exclusive), but got %d\n",
2257+
VME_MAX_SLOTS, geoid);
2258+
return -EINVAL;
2259+
}
2260+
22552261
/* If we want to support more than one of each bridge, we need to
22562262
* dynamically generate this so we get one per device
22572263
*/

0 commit comments

Comments
 (0)