* [PATCH v3] staging: vme_user: added bound check to geoid
@ 2024-08-27 12:56 Riyan Dhiman
2024-08-27 13:06 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Riyan Dhiman @ 2024-08-27 12:56 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, linux-staging, Riyan Dhiman
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>
---
v3: Fix commit message and remove redundant comment.
v2: Removed unnecessary paranthesis and changed pr_err to dev_err.
v1: Added bound check to geoid
drivers/staging/vme_user/vme_fake.c | 6 ++++++
drivers/staging/vme_user/vme_tsi148.c | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c
index 7f84d1c86f29..c4fb2b65154c 100644
--- a/drivers/staging/vme_user/vme_fake.c
+++ b/drivers/staging/vme_user/vme_fake.c
@@ -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))
diff --git a/drivers/staging/vme_user/vme_tsi148.c b/drivers/staging/vme_user/vme_tsi148.c
index d81be8e4ceba..6b6ad781b966 100644
--- a/drivers/staging/vme_user/vme_tsi148.c
+++ b/drivers/staging/vme_user/vme_tsi148.c
@@ -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
*/
--
2.46.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v3] staging: vme_user: added bound check to geoid
2024-08-27 12:56 [PATCH v3] staging: vme_user: added bound check to geoid Riyan Dhiman
@ 2024-08-27 13:06 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2024-08-27 13:06 UTC (permalink / raw)
To: Riyan Dhiman; +Cc: gregkh, linux-kernel, linux-staging
On Tue, Aug 27, 2024 at 06:26:05PM +0530, Riyan Dhiman wrote:
> 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>
> ---
> v3: Fix commit message and remove redundant comment.
> v2: Removed unnecessary paranthesis and changed pr_err to dev_err.
> v1: Added bound check to geoid
>
Thanks!
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-27 13:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-27 12:56 [PATCH v3] staging: vme_user: added bound check to geoid Riyan Dhiman
2024-08-27 13:06 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®