Commit 7029064d authored by Tobin C. Harding's avatar Tobin C. Harding Committed by Greg Kroah-Hartman

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: default avatarTobin C. Harding <me@tobin.cc>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c8863b3f
...@@ -42,25 +42,25 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file) ...@@ -42,25 +42,25 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file)
{ {
unsigned long flags; unsigned long flags;
unsigned int minor = iminor(inode); unsigned int minor = iminor(inode);
int rc = 0;
spin_lock_irqsave(&dgnc_global_lock, flags); spin_lock_irqsave(&dgnc_global_lock, flags);
/* mgmt device */ /* mgmt device */
if (minor < MAXMGMTDEVICES) { if (minor >= MAXMGMTDEVICES) {
rc = -ENXIO;
goto out;
}
/* Only allow 1 open at a time on mgmt device */ /* Only allow 1 open at a time on mgmt device */
if (dgnc_mgmt_in_use[minor]) { if (dgnc_mgmt_in_use[minor]) {
spin_unlock_irqrestore(&dgnc_global_lock, flags); rc = -EBUSY;
return -EBUSY; goto out;
} }
dgnc_mgmt_in_use[minor]++; dgnc_mgmt_in_use[minor]++;
} else {
spin_unlock_irqrestore(&dgnc_global_lock, flags);
return -ENXIO;
}
out:
spin_unlock_irqrestore(&dgnc_global_lock, flags); spin_unlock_irqrestore(&dgnc_global_lock, flags);
return rc;
return 0;
} }
/* /*
...@@ -72,17 +72,20 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file) ...@@ -72,17 +72,20 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file)
{ {
unsigned long flags; unsigned long flags;
unsigned int minor = iminor(inode); unsigned int minor = iminor(inode);
int rc = 0;
spin_lock_irqsave(&dgnc_global_lock, flags); spin_lock_irqsave(&dgnc_global_lock, flags);
/* mgmt device */ /* mgmt device */
if (minor < MAXMGMTDEVICES) { if (minor >= MAXMGMTDEVICES) {
if (dgnc_mgmt_in_use[minor]) rc = -ENXIO;
dgnc_mgmt_in_use[minor] = 0; 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;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment