linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] staging: dgap: introduce dgap_stop()
@ 2014-10-08 11:13 Daeseok Youn
  2014-10-08 11:37 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Daeseok Youn @ 2014-10-08 11:13 UTC (permalink / raw)
  To: lidza.louina, markh
  Cc: markh, daeseok.youn, gregkh, driverdev-devel, devel,
	linux-kernel, dan.carpenter

The dgap_init_module() need to unwind for cleanup variables properly.
Because dgap_init_module() calls dgap_cleanup_module() for freeing
variables but this function is possible to free variables
which are not allocated.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
---
 drivers/staging/dgap/dgap.c |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 7c79fe6..00f34b5 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -71,6 +71,7 @@ MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product lin
 MODULE_SUPPORTED_DEVICE("dgap");
 
 static int dgap_start(void);
+static void dgap_stop(void);
 static void dgap_init_globals(void);
 static struct board_t *dgap_found_board(struct pci_dev *pdev, int id,
 					int boardnum);
@@ -479,19 +480,20 @@ static int dgap_init_module(void)
 
 	rc = pci_register_driver(&dgap_driver);
 	if (rc)
-		goto err_cleanup;
+		goto err_stop;
 
 	rc = dgap_create_driver_sysfiles(&dgap_driver);
 	if (rc)
-		goto err_cleanup;
+		goto err_unregister;
 
 	dgap_driver_state = DRIVER_READY;
 
 	return 0;
 
-err_cleanup:
-
-	dgap_cleanup_module();
+err_unregister:
+	pci_unregister_driver(&dgap_driver);
+err_stop:
+	dgap_stop();
 
 	return rc;
 }
@@ -561,6 +563,21 @@ failed_class:
 	return rc;
 }
 
+static void dgap_stop(void)
+{
+	ulong lock_flags;
+
+	spin_lock_irqsave(&dgap_poll_lock, lock_flags);
+	dgap_poll_stop = 1;
+	spin_unlock_irqrestore(&dgap_poll_lock, lock_flags);
+
+	del_timer_sync(&dgap_poll_timer);
+
+	device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
+	class_destroy(dgap_class);
+	unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
+}
+
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	int rc;
-- 
1.7.1


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

* Re: [PATCH 3/3] staging: dgap: introduce dgap_stop()
  2014-10-08 11:13 [PATCH 3/3] staging: dgap: introduce dgap_stop() Daeseok Youn
@ 2014-10-08 11:37 ` Dan Carpenter
  2014-10-09  1:50   ` DaeSeok Youn
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2014-10-08 11:37 UTC (permalink / raw)
  To: Daeseok Youn
  Cc: lidza.louina, markh, devel, gregkh, driverdev-devel, linux-kernel

All three of these patches are good and a nice improvement.  This one is
a good bugfix.  I have some notes for later, though below.

On Wed, Oct 08, 2014 at 08:13:56PM +0900, Daeseok Youn wrote:
> diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
> index 7c79fe6..00f34b5 100644
> --- a/drivers/staging/dgap/dgap.c
> +++ b/drivers/staging/dgap/dgap.c
> @@ -71,6 +71,7 @@ MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product lin
>  MODULE_SUPPORTED_DEVICE("dgap");
>  
>  static int dgap_start(void);
> +static void dgap_stop(void);

These kinds of forward declarations are annoying.  The whole file needs
to be re-arranged so that we don't have to deal with them.

> @@ -561,6 +563,21 @@ failed_class:
>  	return rc;
>  }
>  
> +static void dgap_stop(void)
> +{
> +	ulong lock_flags;

This is non-standard.  Traditionally it would be:

	unsigned long flags;

regards,
dan carpenter


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

* Re: [PATCH 3/3] staging: dgap: introduce dgap_stop()
  2014-10-08 11:37 ` Dan Carpenter
@ 2014-10-09  1:50   ` DaeSeok Youn
  0 siblings, 0 replies; 3+ messages in thread
From: DaeSeok Youn @ 2014-10-09  1:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Lidza Louina, Mark Hounschell, devel, Greg KH, driverdev-devel,
	linux-kernel

Hi, Dan

2014-10-08 20:37 GMT+09:00 Dan Carpenter <dan.carpenter@oracle.com>:
> All three of these patches are good and a nice improvement.  This one is
> a good bugfix.  I have some notes for later, though below.
>
> On Wed, Oct 08, 2014 at 08:13:56PM +0900, Daeseok Youn wrote:
>> diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
>> index 7c79fe6..00f34b5 100644
>> --- a/drivers/staging/dgap/dgap.c
>> +++ b/drivers/staging/dgap/dgap.c
>> @@ -71,6 +71,7 @@ MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product lin
>>  MODULE_SUPPORTED_DEVICE("dgap");
>>
>>  static int dgap_start(void);
>> +static void dgap_stop(void);
>
> These kinds of forward declarations are annoying.  The whole file needs
> to be re-arranged so that we don't have to deal with them.
OK. I will try to re-arrange and remove forward declarations.

>
>> @@ -561,6 +563,21 @@ failed_class:
>>       return rc;
>>  }
>>
>> +static void dgap_stop(void)
>> +{
>> +     ulong lock_flags;
OK. I will send this patch again after changing ulong to "unsigned long".
>
> This is non-standard.  Traditionally it would be:
>
>         unsigned long flags;
>
> regards,
> dan carpenter

Thanks

regards,
Daeseok Youn
>

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

end of thread, other threads:[~2014-10-09  1:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-08 11:13 [PATCH 3/3] staging: dgap: introduce dgap_stop() Daeseok Youn
2014-10-08 11:37 ` Dan Carpenter
2014-10-09  1:50   ` DaeSeok Youn

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).