drivers/staging/vme_user/vme_fake.c | 4 ++-- drivers/staging/vme_user/vme_tsi148.c | 6 +++--- drivers/staging/vme_user/vme_user.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
Removed unncessesary typecasting to int.
Changed geoid data type to u32 because it will always going to be positive.
Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
---
drivers/staging/vme_user/vme_fake.c | 4 ++--
drivers/staging/vme_user/vme_tsi148.c | 6 +++---
drivers/staging/vme_user/vme_user.c | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c
index 7f84d1c86f29..8d4129c11e73 100644
--- a/drivers/staging/vme_user/vme_fake.c
+++ b/drivers/staging/vme_user/vme_fake.c
@@ -79,7 +79,7 @@ struct fake_driver {
};
/* Module parameter */
-static int geoid;
+static u32 geoid;
static const char driver_name[] = "vme_fake";
@@ -1283,7 +1283,7 @@ static void __exit fake_exit(void)
}
MODULE_PARM_DESC(geoid, "Set geographical addressing");
-module_param(geoid, int, 0);
+module_param(geoid, uint, 0);
MODULE_DESCRIPTION("Fake VME bridge driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/vme_user/vme_tsi148.c b/drivers/staging/vme_user/vme_tsi148.c
index d81be8e4ceba..231eb17b6aa1 100644
--- a/drivers/staging/vme_user/vme_tsi148.c
+++ b/drivers/staging/vme_user/vme_tsi148.c
@@ -36,7 +36,7 @@ static void tsi148_remove(struct pci_dev *);
/* Module parameter */
static bool err_chk;
-static int geoid;
+static u32 geoid;
static const char driver_name[] = "vme_tsi148";
@@ -2123,7 +2123,7 @@ static int tsi148_slot_get(struct vme_bridge *tsi148_bridge)
slot = geoid;
}
- return (int)slot;
+ return slot;
}
static void *tsi148_alloc_consistent(struct device *parent, size_t size,
@@ -2625,7 +2625,7 @@ MODULE_PARM_DESC(err_chk, "Check for VME errors on reads and writes");
module_param(err_chk, bool, 0);
MODULE_PARM_DESC(geoid, "Override geographical addressing");
-module_param(geoid, int, 0);
+module_param(geoid, uint, 0);
MODULE_DESCRIPTION("VME driver for the Tundra Tempe VME bridge");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/vme_user/vme_user.c b/drivers/staging/vme_user/vme_user.c
index 5829a4141561..fe261eef9153 100644
--- a/drivers/staging/vme_user/vme_user.c
+++ b/drivers/staging/vme_user/vme_user.c
@@ -130,7 +130,7 @@ static ssize_t resource_to_user(int minor, char __user *buf, size_t count,
copied = vme_master_read(image[minor].resource, image[minor].kern_buf,
count, *ppos);
if (copied < 0)
- return (int)copied;
+ return copied;
if (copy_to_user(buf, image[minor].kern_buf, (unsigned long)copied))
return -EFAULT;
--
2.46.0
On Mon, Aug 26, 2024 at 08:14:30PM +0530, Riyan Dhiman wrote:
> Removed unncessesary typecasting to int.
> Changed geoid data type to u32 because it will always going to be positive.
>
This does several things that aren't necessarily related. But it really needs
to add some bounds checking to the probe() function to ensure that geoid is < 31.
Here is like a life hack: The one thing per patch rule is slightly ambiguous so
when you're writing commit messages you really need to sell what the one thing
is that you're fixing. But in this case the changes to resource_to_user() are
clearly unrelated.
I am going to give you the most conservative advice. I don't necessarily like
to split it up this way personally but it's the least common denominator path
and we will merge it.
patch 1: add bounds checking
patch 2: change the type to u32 and remove the check for negatives that you
will add in patch 1.
patch 3: remove the cast in tsi148_slot_get()
patch 4: remove the cast in resource_to_user()
regards,
dan carpenter
© 2016 - 2025 Red Hat, Inc.