]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
staging: vme_user: added bound check to geoid
authorRiyan Dhiman <riyandhiman14@gmail.com>
Tue, 27 Aug 2024 12:56:05 +0000 (18:26 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Aug 2024 09:55:55 +0000 (11:55 +0200)
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 <riyandhiman14@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20240827125604.42771-2-riyandhiman14@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vme_user/vme_fake.c
drivers/staging/vme_user/vme_tsi148.c

index 7f84d1c86f291727db741e59e7dc5e19c253f4aa..c4fb2b65154c72b04e48171cf9e886a0d68e4e4f 100644 (file)
@@ -1059,6 +1059,12 @@ static int __init fake_init(void)
        struct vme_slave_resource *slave_image;
        struct vme_lm_resource *lm;
 
+       if (geoid < 0 || geoid >= VME_MAX_SLOTS) {
+               pr_err("VME geographical address must be between 0 and %d (exclusive), but got %d\n",
+                       VME_MAX_SLOTS, geoid);
+               return -EINVAL;
+       }
+
        /* We need a fake parent device */
        vme_root = root_device_register("vme");
        if (IS_ERR(vme_root))
index d81be8e4ceba0903fd7d7ca60da271c8364ef115..6b6ad781b9666b8137e924e5c05d90d50bf49529 100644 (file)
@@ -2252,6 +2252,12 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        struct vme_dma_resource *dma_ctrlr;
        struct vme_lm_resource *lm;
 
+       if (geoid < 0 || geoid >= VME_MAX_SLOTS) {
+               dev_err(&pdev->dev, "VME geographical address must be between 0 and %d (exclusive), but got %d\n",
+                       VME_MAX_SLOTS, geoid);
+               return -EINVAL;
+       }
+
        /* If we want to support more than one of each bridge, we need to
         * dynamically generate this so we get one per device
         */