* [PATCH] staging: vme_user: added bound check to geoid
@ 2024-08-27 9:09 Riyan Dhiman
2024-08-27 9:40 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Riyan Dhiman @ 2024-08-27 9:09 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, linux-staging, Riyan Dhiman
Added bound check for geoid in probe function because geoid will
always be positive and less than VME_MAX_SLOT
Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
---
drivers/staging/vme_user/vme_fake.c | 7 +++++++
drivers/staging/vme_user/vme_tsi148.c | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c
index 7f84d1c86f29..d8f4ba29da0e 100644
--- a/drivers/staging/vme_user/vme_fake.c
+++ b/drivers/staging/vme_user/vme_fake.c
@@ -1059,6 +1059,13 @@ static int __init fake_init(void)
struct vme_slave_resource *slave_image;
struct vme_lm_resource *lm;
+ /* If geoid provided, validate it is positive and less than VME_MAX_SLOTS */
+ 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..9ec981cd2009 100644
--- a/drivers/staging/vme_user/vme_tsi148.c
+++ b/drivers/staging/vme_user/vme_tsi148.c
@@ -2252,6 +2252,13 @@ 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 provided, validate it is positive and less than VME_MAX_SLOTS */
+ 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] 4+ messages in thread
* Re: [PATCH] staging: vme_user: added bound check to geoid
2024-08-27 9:09 [PATCH] staging: vme_user: added bound check to geoid Riyan Dhiman
@ 2024-08-27 9:40 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-08-27 9:40 UTC (permalink / raw)
To: Riyan Dhiman; +Cc: gregkh, linux-kernel, linux-staging
You need to put v2 (v3 now) into the subject.
https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/
On Tue, Aug 27, 2024 at 02:39:55PM +0530, Riyan Dhiman wrote:
> Added bound check for geoid in probe function because geoid will
> always be positive and less than VME_MAX_SLOT
Add a period to the end of the sentence.
But also add that "The geoid variable is a module parameter which lets people
hard code the slot number." It's important to mention that it's a module
parameter so people know that it's root only. Maybe mention that explicitly.
"The geoid variable is a module parameter so it can only be controlled by the
root user. Only values between 0 and VME_MAX_SLOT make sense. Invalid values
don't seem to cause a serious issue except for perhaps some weird error codes."
>
> Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
> ---
> drivers/staging/vme_user/vme_fake.c | 7 +++++++
> drivers/staging/vme_user/vme_tsi148.c | 7 +++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c
> index 7f84d1c86f29..d8f4ba29da0e 100644
> --- a/drivers/staging/vme_user/vme_fake.c
> +++ b/drivers/staging/vme_user/vme_fake.c
> @@ -1059,6 +1059,13 @@ static int __init fake_init(void)
> struct vme_slave_resource *slave_image;
> struct vme_lm_resource *lm;
>
> + /* If geoid provided, validate it is positive and less than VME_MAX_SLOTS */
This comment is obvoius. Just leave it out.
regards,
dan carpener
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: vme_user: added bound check to geoid
2024-08-27 5:55 Riyan Dhiman
@ 2024-08-27 8:40 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-08-27 8:40 UTC (permalink / raw)
To: Riyan Dhiman; +Cc: gregkh, linux-kernel, linux-staging
On Tue, Aug 27, 2024 at 11:25:55AM +0530, Riyan Dhiman wrote:
> diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c
> index 7f84d1c86f29..d93a5d428ab9 100644
> --- a/drivers/staging/vme_user/vme_fake.c
> +++ b/drivers/staging/vme_user/vme_fake.c
> @@ -1059,6 +1059,13 @@ static int __init fake_init(void)
> struct vme_slave_resource *slave_image;
> struct vme_lm_resource *lm;
>
> + /* If geoid provided, validate it is positive and less than VME_MAX_SLOTS */
> + if ((geoid) && (geoid < 0 || geoid >= VME_MAX_SLOTS)) {
^^^^^^^
Too many parentheses, but really there is no need for this. Just write:
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..97323b5563e8 100644
> --- a/drivers/staging/vme_user/vme_tsi148.c
> +++ b/drivers/staging/vme_user/vme_tsi148.c
> @@ -2252,6 +2252,13 @@ 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 provided, validate it is positive and less than VME_MAX_SLOTS */
> + if ((geoid) && (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);
Here you have a device pointer so can use dev_err(&pdev->dev, ... instead of
pr_err().
regards,
dan carpenter
> + return -EINVAL;
> + }
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] staging: vme_user: added bound check to geoid
@ 2024-08-27 5:55 Riyan Dhiman
2024-08-27 8:40 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Riyan Dhiman @ 2024-08-27 5:55 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, linux-staging, Riyan Dhiman
Added bound check for geoid in probe function because geoid will
always be positive and less than VME_MAX_SLOTS
Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
---
drivers/staging/vme_user/vme_fake.c | 7 +++++++
drivers/staging/vme_user/vme_tsi148.c | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c
index 7f84d1c86f29..d93a5d428ab9 100644
--- a/drivers/staging/vme_user/vme_fake.c
+++ b/drivers/staging/vme_user/vme_fake.c
@@ -1059,6 +1059,13 @@ static int __init fake_init(void)
struct vme_slave_resource *slave_image;
struct vme_lm_resource *lm;
+ /* If geoid provided, validate it is positive and less than VME_MAX_SLOTS */
+ if ((geoid) && (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..97323b5563e8 100644
--- a/drivers/staging/vme_user/vme_tsi148.c
+++ b/drivers/staging/vme_user/vme_tsi148.c
@@ -2252,6 +2252,13 @@ 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 provided, validate it is positive and less than VME_MAX_SLOTS */
+ if ((geoid) && (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;
+ }
+
/* 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] 4+ messages in thread
end of thread, other threads:[~2024-08-27 9:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-27 9:09 [PATCH] staging: vme_user: added bound check to geoid Riyan Dhiman
2024-08-27 9:40 ` Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2024-08-27 5:55 Riyan Dhiman
2024-08-27 8:40 ` 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®