chardev: set variable ret to -EBUSY before checking minor range overlap
PATCH RESEND 1/1 chardev: set variable ret to -EBUSY before checking minor range overlap
When allocating dynamic major, the minor range overlap check in __register_chrdev_region() will not fail, so actually there is no real case to passing non negative error code to caller. However, set variable ret to -EBUSY before chekcking minor range overlap will avoid false-positive warning from code analyzing tool(like Smatch) and also make the code more easy to understand.
--- fs/char_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/char_dev.c +2 -1
@@ -98,7 +98,7 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, int minorct, const char *name) { struct char_device_struct *cd, *curr, *prev = NULL; -int ret = -EBUSY ; +int ret;int i;if (major >=CHRDEV_MAJOR_MAX ) {
@@ -129,6 +129,7 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, major = ret; } + ret = -EBUSY ; i =major_to_index (major);for (curr = chrdevs[i]; curr; prev = curr, curr = curr->next) {if (curr->major < major)
--
2.20.1
Please don't say RESEND, say [PATCH v2]. RESEND is for when we ignored your patch. (Maybe we made a mistake or maybe the mailing list tagged it as spam and deleted it or something). Use [PATCH v2] instead.
Quoted 11 lines · Chengguang Xu
When allocating dynamic major, the minor range overlap check in
__register_chrdev_region()will not fail, so actually there is no real case to passing non negative error code to caller. However, set variable ret to-EBUSYbefore chekcking minor range overlap will avoid false-positive warning from code analyzing tool(like Smatch) and also make the code more easy to understand.Suggested-by Dan Carpenter <[email protected]>Signed-off-by Chengguang Xu <[email protected]>---
Then here under the --- cut off line put:
v2: rebase against the latest linux-next
That way we will remember why the patch was sent twice and what changed.
Quoted 3 lines
fs/char_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
regards,
dan carpenter