All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] xhci: solve a double free problem while doing s4
       [not found] <1623403104-121391-1-git-send-email-xuetao09@huawei.com>
@ 2021-06-11 11:08 ` Zhangjiantao (Kirin, nanjing)
  2021-06-11 13:13   ` gregkh
  0 siblings, 1 reply; 4+ messages in thread
From: Zhangjiantao (Kirin, nanjing) @ 2021-06-11 11:08 UTC (permalink / raw)
  To: mathias.nyman, gregkh, linux-usb, linux-kernel
  Cc: Xuetao (kirin), chenyu (U),
	Caiyadong, xuhaiyang, Zhangjiantao (Kirin, nanjing)

when system is doing s4, the process of xhci_resume may be as below:
1、xhci_mem_cleanup
2、xhci_init->xhci_mem_init->xhci_mem_cleanup(when memory is not enough).
xhci_mem_cleanup will be executed twice when system is out of memory.
xhci->port_caps is freed in xhci_mem_cleanup,but it isn't set to NULL.
It will be freed twice when xhci_mem_cleanup is called the second time.

We got following bug when system resumes from s4:

kernel BUG at mm/slub.c:309!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
CPU: 0 PID: 5929 Tainted: G S   W   5.4.96-arm64-desktop #1
pc : __slab_free+0x5c/0x424
lr : kfree+0x30c/0x32c

Call trace:
 __slab_free+0x5c/0x424
 kfree+0x30c/0x32c
 xhci_mem_cleanup+0x394/0x3cc
 xhci_mem_init+0x9ac/0x1070
 xhci_init+0x8c/0x1d0
 xhci_resume+0x1cc/0x5fc
 xhci_plat_resume+0x64/0x70
 platform_pm_thaw+0x28/0x60
 dpm_run_callback+0x54/0x24c
 device_resume+0xd0/0x200
 async_resume+0x24/0x60
 async_run_entry_fn+0x44/0x110
 process_one_work+0x1f0/0x490
 worker_thread+0x5c/0x450
 kthread+0x158/0x160
 ret_from_fork+0x10/0x24

Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com>
Signed-off-by: Tao Xue <xuetao09@huawei.com>
---
 drivers/usb/host/xhci-mem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index f66815f..e4b0c04 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1924,6 +1924,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
 	xhci->hw_ports = NULL;
 	xhci->rh_bw = NULL;
 	xhci->ext_caps = NULL;
+	xhci->port_caps = NULL;
 
 	xhci->page_size = 0;
 	xhci->page_shift = 0;
--
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] xhci: solve a double free problem while doing s4
  2021-06-11 11:08 ` [PATCH v2] xhci: solve a double free problem while doing s4 Zhangjiantao (Kirin, nanjing)
@ 2021-06-11 13:13   ` gregkh
  2021-06-13 12:08     ` Zhangjiantao (Kirin, nanjing)
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2021-06-11 13:13 UTC (permalink / raw)
  To: Zhangjiantao (Kirin, nanjing)
  Cc: mathias.nyman, linux-usb, linux-kernel, Xuetao (kirin),
	chenyu (U),
	Caiyadong, xuhaiyang

On Fri, Jun 11, 2021 at 11:08:30AM +0000, Zhangjiantao (Kirin, nanjing) wrote:
> when system is doing s4, the process of xhci_resume may be as below:
> 1、xhci_mem_cleanup
> 2、xhci_init->xhci_mem_init->xhci_mem_cleanup(when memory is not enough).
> xhci_mem_cleanup will be executed twice when system is out of memory.
> xhci->port_caps is freed in xhci_mem_cleanup,but it isn't set to NULL.
> It will be freed twice when xhci_mem_cleanup is called the second time.
> 
> We got following bug when system resumes from s4:
> 
> kernel BUG at mm/slub.c:309!
> Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
> CPU: 0 PID: 5929 Tainted: G S   W   5.4.96-arm64-desktop #1
> pc : __slab_free+0x5c/0x424
> lr : kfree+0x30c/0x32c
> 
> Call trace:
>  __slab_free+0x5c/0x424
>  kfree+0x30c/0x32c
>  xhci_mem_cleanup+0x394/0x3cc
>  xhci_mem_init+0x9ac/0x1070
>  xhci_init+0x8c/0x1d0
>  xhci_resume+0x1cc/0x5fc
>  xhci_plat_resume+0x64/0x70
>  platform_pm_thaw+0x28/0x60
>  dpm_run_callback+0x54/0x24c
>  device_resume+0xd0/0x200
>  async_resume+0x24/0x60
>  async_run_entry_fn+0x44/0x110
>  process_one_work+0x1f0/0x490
>  worker_thread+0x5c/0x450
>  kthread+0x158/0x160
>  ret_from_fork+0x10/0x24
> 
> Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com>
> Signed-off-by: Tao Xue <xuetao09@huawei.com>
> ---
>  drivers/usb/host/xhci-mem.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index f66815f..e4b0c04 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -1924,6 +1924,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
>  	xhci->hw_ports = NULL;
>  	xhci->rh_bw = NULL;
>  	xhci->ext_caps = NULL;
> +	xhci->port_caps = NULL;
>  
>  	xhci->page_size = 0;
>  	xhci->page_shift = 0;
> --
> 2.7.4
> 


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] 4+ messages in thread

* Re: [PATCH v2] xhci: solve a double free problem while doing s4
  2021-06-11 13:13   ` gregkh
@ 2021-06-13 12:08     ` Zhangjiantao (Kirin, nanjing)
  2021-06-14 10:21       ` Mathias Nyman
  0 siblings, 1 reply; 4+ messages in thread
From: Zhangjiantao (Kirin, nanjing) @ 2021-06-13 12:08 UTC (permalink / raw)
  To: gregkh
  Cc: mathias.nyman, linux-usb, linux-kernel, Xuetao (kirin),
	chenyu (U),
	Caiyadong, xuhaiyang


On 2021/6/11 21:13, gregkh@linuxfoundation.org wrote :
> On Fri, Jun 11, 2021 at 11:08:30AM +0000, Zhangjiantao (Kirin, nanjing) wrote:
>> when system is doing s4, the process of xhci_resume may be as below:
>> 1、xhci_mem_cleanup
>> 2、xhci_init->xhci_mem_init->xhci_mem_cleanup(when memory is not enough).
>> xhci_mem_cleanup will be executed twice when system is out of memory.
>> xhci->port_caps is freed in xhci_mem_cleanup,but it isn't set to NULL.
>> It will be freed twice when xhci_mem_cleanup is called the second time.
>>
>> We got following bug when system resumes from s4:
>>
>> kernel BUG at mm/slub.c:309!
>> Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
>> CPU: 0 PID: 5929 Tainted: G S   W   5.4.96-arm64-desktop #1
>> pc : __slab_free+0x5c/0x424
>> lr : kfree+0x30c/0x32c
>>
>> Call trace:
>>   __slab_free+0x5c/0x424
>>   kfree+0x30c/0x32c
>>   xhci_mem_cleanup+0x394/0x3cc
>>   xhci_mem_init+0x9ac/0x1070
>>   xhci_init+0x8c/0x1d0
>>   xhci_resume+0x1cc/0x5fc
>>   xhci_plat_resume+0x64/0x70
>>   platform_pm_thaw+0x28/0x60
>>   dpm_run_callback+0x54/0x24c
>>   device_resume+0xd0/0x200
>>   async_resume+0x24/0x60
>>   async_run_entry_fn+0x44/0x110
>>   process_one_work+0x1f0/0x490
>>   worker_thread+0x5c/0x450
>>   kthread+0x158/0x160
>>   ret_from_fork+0x10/0x24
>>
>> Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com>
>> Signed-off-by: Tao Xue <xuetao09@huawei.com>
>> ---
>>   drivers/usb/host/xhci-mem.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index f66815f..e4b0c04 100644
>> --- a/drivers/usb/host/xhci-mem.c
>> +++ b/drivers/usb/host/xhci-mem.c
>> @@ -1924,6 +1924,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
>>   	xhci->hw_ports = NULL;
>>   	xhci->rh_bw = NULL;
>>   	xhci->ext_caps = NULL;
>> +	xhci->port_caps = NULL;
>>   
>>   	xhci->page_size = 0;
>>   	xhci->page_shift = 0;
>> --
>> 2.7.4
>>
>
> 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

Yes,there is no change of code line. I only added
"Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com>" in the comments.
thanks,
    Jiantao Zhang


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] xhci: solve a double free problem while doing s4
  2021-06-13 12:08     ` Zhangjiantao (Kirin, nanjing)
@ 2021-06-14 10:21       ` Mathias Nyman
  0 siblings, 0 replies; 4+ messages in thread
From: Mathias Nyman @ 2021-06-14 10:21 UTC (permalink / raw)
  To: Zhangjiantao (Kirin, nanjing), gregkh
  Cc: mathias.nyman, linux-usb, linux-kernel, Xuetao (kirin),
	chenyu (U),
	Caiyadong, xuhaiyang

On 13.6.2021 15.08, Zhangjiantao (Kirin, nanjing) wrote:
> 
> On 2021/6/11 21:13, gregkh@linuxfoundation.org wrote :
>> On Fri, Jun 11, 2021 at 11:08:30AM +0000, Zhangjiantao (Kirin, nanjing) wrote:
>>> when system is doing s4, the process of xhci_resume may be as below:
>>> 1、xhci_mem_cleanup
>>> 2、xhci_init->xhci_mem_init->xhci_mem_cleanup(when memory is not enough).
>>> xhci_mem_cleanup will be executed twice when system is out of memory.
>>> xhci->port_caps is freed in xhci_mem_cleanup,but it isn't set to NULL.
>>> It will be freed twice when xhci_mem_cleanup is called the second time.
>>>
>>> We got following bug when system resumes from s4:
>>>
>>> kernel BUG at mm/slub.c:309!
>>> Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
>>> CPU: 0 PID: 5929 Tainted: G S   W   5.4.96-arm64-desktop #1
>>> pc : __slab_free+0x5c/0x424
>>> lr : kfree+0x30c/0x32c
>>>
>>> Call trace:
>>>   __slab_free+0x5c/0x424
>>>   kfree+0x30c/0x32c
>>>   xhci_mem_cleanup+0x394/0x3cc
>>>   xhci_mem_init+0x9ac/0x1070
>>>   xhci_init+0x8c/0x1d0
>>>   xhci_resume+0x1cc/0x5fc
>>>   xhci_plat_resume+0x64/0x70
>>>   platform_pm_thaw+0x28/0x60
>>>   dpm_run_callback+0x54/0x24c
>>>   device_resume+0xd0/0x200
>>>   async_resume+0x24/0x60
>>>   async_run_entry_fn+0x44/0x110
>>>   process_one_work+0x1f0/0x490
>>>   worker_thread+0x5c/0x450
>>>   kthread+0x158/0x160
>>>   ret_from_fork+0x10/0x24
>>>
>>> Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com>
>>> Signed-off-by: Tao Xue <xuetao09@huawei.com>
>>> ---
>>>   drivers/usb/host/xhci-mem.c | 1 +
>>>   1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index f66815f..e4b0c04 100644
>>> --- a/drivers/usb/host/xhci-mem.c
>>> +++ b/drivers/usb/host/xhci-mem.c
>>> @@ -1924,6 +1924,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
>>>       xhci->hw_ports = NULL;
>>>       xhci->rh_bw = NULL;
>>>       xhci->ext_caps = NULL;
>>> +    xhci->port_caps = NULL;
>>>         xhci->page_size = 0;
>>>       xhci->page_shift = 0;
>>> -- 
>>> 2.7.4
>>>
>>
>> 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
> 
> Yes,there is no change of code line. I only added
> "Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com>" in the comments.
> thanks,
>    Jiantao Zhang
> 

I'll pick this up, add stable and fixes tags and send it forward.

Thanks
-Mathias

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-14 10:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1623403104-121391-1-git-send-email-xuetao09@huawei.com>
2021-06-11 11:08 ` [PATCH v2] xhci: solve a double free problem while doing s4 Zhangjiantao (Kirin, nanjing)
2021-06-11 13:13   ` gregkh
2021-06-13 12:08     ` Zhangjiantao (Kirin, nanjing)
2021-06-14 10:21       ` Mathias Nyman

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.