* [PATCH] node: put_device after failing to device_register
@ 2022-06-14 14:30 Zhi Song
2022-06-14 14:37 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Zhi Song @ 2022-06-14 14:30 UTC (permalink / raw)
To: gregkh, rafael; +Cc: linux-kernel, Zhi Song
device_register() is used to register a device with the system.
We cannot directly free dev after calling this function,
even if it returns an error.
We should use put_device() to give up the reference
initialized in this function instead.
Signed-off-by: Zhi Song <zhi.song@bytedance.com>
---
drivers/base/node.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 0ac6376ef7a1..88a3337c546e 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -154,6 +154,7 @@ static struct node_access_nodes *node_init_node_access(struct node *node,
list_add_tail(&access_node->list_node, &node->access_list);
return access_node;
free_name:
+ put_device(dev);
kfree_const(dev->kobj.name);
free:
kfree(access_node);
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] node: put_device after failing to device_register
2022-06-14 14:30 [PATCH] node: put_device after failing to device_register Zhi Song
@ 2022-06-14 14:37 ` Greg KH
2022-06-22 17:12 ` [External] " Zhi Song
0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2022-06-14 14:37 UTC (permalink / raw)
To: Zhi Song; +Cc: rafael, linux-kernel
On Tue, Jun 14, 2022 at 10:30:07PM +0800, Zhi Song wrote:
> device_register() is used to register a device with the system.
>
> We cannot directly free dev after calling this function,
> even if it returns an error.
the device is not being freed, why say this?
And you do have a full 72 columns to use :)
>
> We should use put_device() to give up the reference
> initialized in this function instead.
There is no "instead" happening here. The patch looks correct, but this
changelog text does not. Please fix up.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] node: put_device after failing to device_register
@ 2022-06-14 16:00 Zhi Song
2022-06-14 16:07 ` Greg KH
0 siblings, 1 reply; 5+ messages in thread
From: Zhi Song @ 2022-06-14 16:00 UTC (permalink / raw)
To: gregkh, rafael; +Cc: linux-kernel, Zhi Song
device_register() is used to register a device with the system.
We need to call put_device() to give up the reference initialized
in device_register() when it returns an error and this will clean
up correctly.
Signed-off-by: Zhi Song <zhi.song@bytedance.com>
---
drivers/base/node.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 0ac6376ef7a1..88a3337c546e 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -154,6 +154,7 @@ static struct node_access_nodes *node_init_node_access(struct node *node,
list_add_tail(&access_node->list_node, &node->access_list);
return access_node;
free_name:
+ put_device(dev);
kfree_const(dev->kobj.name);
free:
kfree(access_node);
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] node: put_device after failing to device_register
2022-06-14 16:00 Zhi Song
@ 2022-06-14 16:07 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2022-06-14 16:07 UTC (permalink / raw)
To: Zhi Song; +Cc: rafael, linux-kernel
On Wed, Jun 15, 2022 at 12:00:59AM +0800, Zhi Song wrote:
> device_register() is used to register a device with the system.
> We need to call put_device() to give up the reference initialized
> in device_register() when it returns an error and this will clean
> up correctly.
>
> Signed-off-by: Zhi Song <zhi.song@bytedance.com>
> ---
> drivers/base/node.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/base/node.c b/drivers/base/node.c
> index 0ac6376ef7a1..88a3337c546e 100644
> --- a/drivers/base/node.c
> +++ b/drivers/base/node.c
> @@ -154,6 +154,7 @@ static struct node_access_nodes *node_init_node_access(struct node *node,
> list_add_tail(&access_node->list_node, &node->access_list);
> return access_node;
> free_name:
> + put_device(dev);
> kfree_const(dev->kobj.name);
> free:
> kfree(access_node);
> --
> 2.30.2
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- This looks like a new version of a previously submitted patch, but you
did not list below the --- line any changes from the previous version.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/SubmittingPatches for what needs to be done
here to properly describe this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [External] [PATCH] node: put_device after failing to device_register
2022-06-14 14:37 ` Greg KH
@ 2022-06-22 17:12 ` Zhi Song
0 siblings, 0 replies; 5+ messages in thread
From: Zhi Song @ 2022-06-22 17:12 UTC (permalink / raw)
To: Greg KH; +Cc: rafael, linux-kernel
> On Jun 14, 2022, at 22:37, Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Tue, Jun 14, 2022 at 10:30:07PM +0800, Zhi Song wrote:
>> device_register() is used to register a device with the system.
>>
>> We cannot directly free dev after calling this function,
>> even if it returns an error.
>
> the device is not being freed, why say this?
>
> And you do have a full 72 columns to use :)
>
>>
>> We should use put_device() to give up the reference
>> initialized in this function instead.
>
> There is no "instead" happening here. The patch looks correct, but this
> changelog text does not. Please fix up.
>
> thanks,
>
> greg k-h
Hi Greg,
I have submitted this fixed patch here:
https://lore.kernel.org/all/20220621171623.1959231-1-zhi.song@bytedance
.com/
take a look if there's anything wrong. :)
Thanks,
Zhi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-22 17:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-14 14:30 [PATCH] node: put_device after failing to device_register Zhi Song
2022-06-14 14:37 ` Greg KH
2022-06-22 17:12 ` [External] " Zhi Song
-- strict thread matches above, loose matches on Subject: below --
2022-06-14 16:00 Zhi Song
2022-06-14 16:07 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox