I follow Dan Carpenter's advices and I update my patch. I just add goto statements for error handling. Good bye. Signed-off-by: Francis Laniel <laniel_francis@xxxxxxxxxxxxx> --- drivers/staging/dgnc/dgnc_mgmt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c index 9d9b15d..3534b29 100644 --- a/drivers/staging/dgnc/dgnc_mgmt.c +++ b/drivers/staging/dgnc/dgnc_mgmt.c @@ -42,6 +42,7 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file) { unsigned long flags; unsigned int minor = iminor(inode); + int rc = 0; spin_lock_irqsave(&dgnc_global_lock, flags); @@ -49,18 +50,19 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file) if (minor < MAXMGMTDEVICES) { /* Only allow 1 open at a time on mgmt device */ if (dgnc_mgmt_in_use[minor]) { - spin_unlock_irqrestore(&dgnc_global_lock, flags); - return -EBUSY; + goto unlock; + rc = -EBUSY; } dgnc_mgmt_in_use[minor]++; } else { - spin_unlock_irqrestore(&dgnc_global_lock, flags); - return -ENXIO; + goto unlock; + rc = -ENXIO; } +unlock: spin_unlock_irqrestore(&dgnc_global_lock, flags); - return 0; + return rc; } /* -- 2.9.3 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel