diff options
author | Tobin C. Harding <me@tobin.cc> | 2017-03-07 20:57:02 +1100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-12 14:46:34 +0100 |
commit | 7029064dd16b975139fb2bc739b8e094400c21d8 (patch) | |
tree | 2b27104b8261b7b156504ee4858c1df5bf569072 /drivers/staging/dgnc | |
parent | c8863b3ff7749c22c1745b7358d15456f86044f7 (diff) | |
download | linux-7029064dd16b975139fb2bc739b8e094400c21d8.tar.bz2 |
staging: dgnc: audit goto's in dgnc_mgmt
TODO file requests fix up of error handling.
Audit dgnc_mgmt.c and fix all return paths to be uniform and inline
with kernel coding style.
Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/dgnc')
-rw-r--r-- | drivers/staging/dgnc/dgnc_mgmt.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c index 9d9b15d6358a..9e984ebea8f9 100644 --- a/drivers/staging/dgnc/dgnc_mgmt.c +++ b/drivers/staging/dgnc/dgnc_mgmt.c @@ -42,25 +42,25 @@ 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); /* mgmt device */ - 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; - } - dgnc_mgmt_in_use[minor]++; - } else { - spin_unlock_irqrestore(&dgnc_global_lock, flags); - return -ENXIO; + if (minor >= MAXMGMTDEVICES) { + rc = -ENXIO; + goto out; } + /* Only allow 1 open at a time on mgmt device */ + if (dgnc_mgmt_in_use[minor]) { + rc = -EBUSY; + goto out; + } + dgnc_mgmt_in_use[minor]++; +out: spin_unlock_irqrestore(&dgnc_global_lock, flags); - - return 0; + return rc; } /* @@ -72,17 +72,20 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file) { unsigned long flags; unsigned int minor = iminor(inode); + int rc = 0; spin_lock_irqsave(&dgnc_global_lock, flags); /* mgmt device */ - if (minor < MAXMGMTDEVICES) { - if (dgnc_mgmt_in_use[minor]) - dgnc_mgmt_in_use[minor] = 0; + if (minor >= MAXMGMTDEVICES) { + rc = -ENXIO; + goto out; } - spin_unlock_irqrestore(&dgnc_global_lock, flags); + dgnc_mgmt_in_use[minor] = 0; - return 0; +out: + spin_unlock_irqrestore(&dgnc_global_lock, flags); + return rc; } /* |