* [PATCH] chardev: set variable ret to -EBUSY before checking minor range overlap
@ 2019-04-05 13:53 Chengguang Xu
2019-04-25 19:49 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Chengguang Xu @ 2019-04-05 13:53 UTC (permalink / raw)
To: gregkh, dan.carpenter; +Cc: linux-fsdevel, linux-kernel, 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 -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.
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
fs/char_dev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/char_dev.c b/fs/char_dev.c
index df6a54045ac4..00dfe17871ac 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -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.17.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] chardev: set variable ret to -EBUSY before checking minor range overlap
2019-04-05 13:53 [PATCH] chardev: set variable ret to -EBUSY before checking minor range overlap Chengguang Xu
@ 2019-04-25 19:49 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-04-25 19:49 UTC (permalink / raw)
To: Chengguang Xu; +Cc: dan.carpenter, linux-fsdevel, linux-kernel
On Fri, Apr 05, 2019 at 09:53:06PM +0800, Chengguang Xu wrote:
> 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.
>
> Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
> fs/char_dev.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
What tree was this patch made against? I can't seem to apply it
anywhere :(
Please fix up and resend.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-25 19:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-05 13:53 [PATCH] chardev: set variable ret to -EBUSY before checking minor range overlap Chengguang Xu
2019-04-25 19:49 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.