diff options
author | Andy Fleming <afleming@freescale.com> | 2008-05-02 14:00:30 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-05-06 12:01:34 -0400 |
commit | f162b9d58273a9a5747211133c8ccb2de5cf5ff2 (patch) | |
tree | 1ee677ebfe4cc3ecf4e2b9deffda26a264c1426c /drivers/net/gianfar_sysfs.c | |
parent | 569f0c4d909c7f73de634abcdc36344cb72de36a (diff) |
gianfar: Fix a locking bug in gianfar's sysfs code
During sparse cleanup, found a locking bug. Some of the sysfs functions were
acquiring a lock, and then returning in the event of an error. We rearrange
the code so that the lock is released in error conditions, too.
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/gianfar_sysfs.c')
-rw-r--r-- | drivers/net/gianfar_sysfs.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c index 230878b94190..5116f68e01b9 100644 --- a/drivers/net/gianfar_sysfs.c +++ b/drivers/net/gianfar_sysfs.c | |||
@@ -103,10 +103,10 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev, | |||
103 | 103 | ||
104 | spin_lock_irqsave(&priv->rxlock, flags); | 104 | spin_lock_irqsave(&priv->rxlock, flags); |
105 | if (length > priv->rx_buffer_size) | 105 | if (length > priv->rx_buffer_size) |
106 | return count; | 106 | goto out; |
107 | 107 | ||
108 | if (length == priv->rx_stash_size) | 108 | if (length == priv->rx_stash_size) |
109 | return count; | 109 | goto out; |
110 | 110 | ||
111 | priv->rx_stash_size = length; | 111 | priv->rx_stash_size = length; |
112 | 112 | ||
@@ -125,6 +125,7 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev, | |||
125 | 125 | ||
126 | gfar_write(&priv->regs->attr, temp); | 126 | gfar_write(&priv->regs->attr, temp); |
127 | 127 | ||
128 | out: | ||
128 | spin_unlock_irqrestore(&priv->rxlock, flags); | 129 | spin_unlock_irqrestore(&priv->rxlock, flags); |
129 | 130 | ||
130 | return count; | 131 | return count; |
@@ -154,10 +155,10 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev, | |||
154 | 155 | ||
155 | spin_lock_irqsave(&priv->rxlock, flags); | 156 | spin_lock_irqsave(&priv->rxlock, flags); |
156 | if (index > priv->rx_stash_size) | 157 | if (index > priv->rx_stash_size) |
157 | return count; | 158 | goto out; |
158 | 159 | ||
159 | if (index == priv->rx_stash_index) | 160 | if (index == priv->rx_stash_index) |
160 | return count; | 161 | goto out; |
161 | 162 | ||
162 | priv->rx_stash_index = index; | 163 | priv->rx_stash_index = index; |
163 | 164 | ||
@@ -166,6 +167,7 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev, | |||
166 | temp |= ATTRELI_EI(index); | 167 | temp |= ATTRELI_EI(index); |
167 | gfar_write(&priv->regs->attreli, flags); | 168 | gfar_write(&priv->regs->attreli, flags); |
168 | 169 | ||
170 | out: | ||
169 | spin_unlock_irqrestore(&priv->rxlock, flags); | 171 | spin_unlock_irqrestore(&priv->rxlock, flags); |
170 | 172 | ||
171 | return count; | 173 | return count; |