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

Commit a8a8b54

Browse files
Ryand1234gregkh
authored andcommitted
staging: vme_user: added bound check to geoid
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]>
1 parent c692c1b commit a8a8b54

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
@@ -1059,6 +1059,12 @@ static int __init fake_init(void)
10591059
struct vme_slave_resource *slave_image;
10601060
struct vme_lm_resource *lm;
10611061

1062+
if (geoid < 0 || geoid >= VME_MAX_SLOTS) {
1063+
pr_err("VME geographical address must be between 0 and %d (exclusive), but got %d\n",
1064+
VME_MAX_SLOTS, geoid);
1065+
return -EINVAL;
1066+
}
1067+
10621068
/* We need a fake parent device */
10631069
vme_root = root_device_register("vme");
10641070
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)