linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: host: u132-hcd: Remove u132_static_list
@ 2020-04-02 23:22 madhuparnabhowmik10
  2020-04-03 14:39 ` Alan Stern
  0 siblings, 1 reply; 3+ messages in thread
From: madhuparnabhowmik10 @ 2020-04-02 23:22 UTC (permalink / raw)
  To: gregkh, hariprasad.kelam, colin.king
  Cc: linux-usb, linux-kernel, ldv-project, andrianov, stern,
	Madhuparna Bhowmik

From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>

u132_static_list is a global list protected by u132_module_lock.
It is read in the u132_hcd_exit() function without holding the lock
thus may lead to data race.
However, it turns out that this list isn't used for anything useful
and thus it is okay to get rid of it.
Thus, remove the u132_static_list from u132-hcd module.

Found by Linux Driver Verification project (linuxtesting.org).

Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
---
 drivers/usb/host/u132-hcd.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index e9209e3e6248..52f70cf063ea 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -81,7 +81,6 @@ static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
 static struct mutex u132_module_lock;
 static int u132_exiting;
 static int u132_instances;
-static struct list_head u132_static_list;
 /*
 * end of the global variables protected by u132_module_lock
 */
@@ -3089,7 +3088,6 @@ static int u132_probe(struct platform_device *pdev)
 		retval = 0;
 		hcd->rsrc_start = 0;
 		mutex_lock(&u132_module_lock);
-		list_add_tail(&u132->u132_list, &u132_static_list);
 		u132->sequence_num = ++u132_instances;
 		mutex_unlock(&u132_module_lock);
 		u132_u132_init_kref(u132);
@@ -3192,7 +3190,6 @@ static struct platform_driver u132_platform_driver = {
 static int __init u132_hcd_init(void)
 {
 	int retval;
-	INIT_LIST_HEAD(&u132_static_list);
 	u132_instances = 0;
 	u132_exiting = 0;
 	mutex_init(&u132_module_lock);
@@ -3213,14 +3210,9 @@ static int __init u132_hcd_init(void)
 module_init(u132_hcd_init);
 static void __exit u132_hcd_exit(void)
 {
-	struct u132 *u132;
-	struct u132 *temp;
 	mutex_lock(&u132_module_lock);
 	u132_exiting += 1;
 	mutex_unlock(&u132_module_lock);
-	list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) {
-		platform_device_unregister(u132->platform_dev);
-	}
 	platform_driver_unregister(&u132_platform_driver);
 	printk(KERN_INFO "u132-hcd driver deregistered\n");
 	wait_event(u132_hcd_wait, u132_instances == 0);
-- 
2.17.1


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

* Re: [PATCH] usb: host: u132-hcd: Remove u132_static_list
  2020-04-02 23:22 [PATCH] usb: host: u132-hcd: Remove u132_static_list madhuparnabhowmik10
@ 2020-04-03 14:39 ` Alan Stern
  2020-04-03 18:11   ` Madhuparna Bhowmik
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Stern @ 2020-04-03 14:39 UTC (permalink / raw)
  To: Madhuparna Bhowmik
  Cc: gregkh, hariprasad.kelam, colin.king, linux-usb, linux-kernel,
	ldv-project, andrianov

On Fri, 3 Apr 2020 madhuparnabhowmik10@gmail.com wrote:

> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> 
> u132_static_list is a global list protected by u132_module_lock.
> It is read in the u132_hcd_exit() function without holding the lock
> thus may lead to data race.
> However, it turns out that this list isn't used for anything useful
> and thus it is okay to get rid of it.
> Thus, remove the u132_static_list from u132-hcd module.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Suggested-by: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> ---
>  drivers/usb/host/u132-hcd.c | 8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
> index e9209e3e6248..52f70cf063ea 100644
> --- a/drivers/usb/host/u132-hcd.c
> +++ b/drivers/usb/host/u132-hcd.c
> @@ -81,7 +81,6 @@ static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
>  static struct mutex u132_module_lock;
>  static int u132_exiting;
>  static int u132_instances;
> -static struct list_head u132_static_list;
>  /*
>  * end of the global variables protected by u132_module_lock
>  */

You forgot to remove the u132_list member from struct u132.

Alan Stern


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

* Re: [PATCH] usb: host: u132-hcd: Remove u132_static_list
  2020-04-03 14:39 ` Alan Stern
@ 2020-04-03 18:11   ` Madhuparna Bhowmik
  0 siblings, 0 replies; 3+ messages in thread
From: Madhuparna Bhowmik @ 2020-04-03 18:11 UTC (permalink / raw)
  To: Alan Stern
  Cc: Madhuparna Bhowmik, gregkh, hariprasad.kelam, colin.king,
	linux-usb, linux-kernel, ldv-project, andrianov

On Fri, Apr 03, 2020 at 10:39:33AM -0400, Alan Stern wrote:
> On Fri, 3 Apr 2020 madhuparnabhowmik10@gmail.com wrote:
> 
> > From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > 
> > u132_static_list is a global list protected by u132_module_lock.
> > It is read in the u132_hcd_exit() function without holding the lock
> > thus may lead to data race.
> > However, it turns out that this list isn't used for anything useful
> > and thus it is okay to get rid of it.
> > Thus, remove the u132_static_list from u132-hcd module.
> > 
> > Found by Linux Driver Verification project (linuxtesting.org).
> > 
> > Suggested-by: Alan Stern <stern@rowland.harvard.edu>
> > Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > ---
> >  drivers/usb/host/u132-hcd.c | 8 --------
> >  1 file changed, 8 deletions(-)
> > 
> > diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
> > index e9209e3e6248..52f70cf063ea 100644
> > --- a/drivers/usb/host/u132-hcd.c
> > +++ b/drivers/usb/host/u132-hcd.c
> > @@ -81,7 +81,6 @@ static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
> >  static struct mutex u132_module_lock;
> >  static int u132_exiting;
> >  static int u132_instances;
> > -static struct list_head u132_static_list;
> >  /*
> >  * end of the global variables protected by u132_module_lock
> >  */
> 
> You forgot to remove the u132_list member from struct u132.
>
Thank you for letting me know, I will send the patch again with this
change.

Regards,
Madhuparna

> Alan Stern
> 

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

end of thread, other threads:[~2020-04-03 18:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 23:22 [PATCH] usb: host: u132-hcd: Remove u132_static_list madhuparnabhowmik10
2020-04-03 14:39 ` Alan Stern
2020-04-03 18:11   ` Madhuparna Bhowmik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).