aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndy Fleming <afleming@freescale.com>2008-05-02 14:00:30 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-05-06 12:01:34 -0400
commitf162b9d58273a9a5747211133c8ccb2de5cf5ff2 (patch)
tree1ee677ebfe4cc3ecf4e2b9deffda26a264c1426c /drivers
parent569f0c4d909c7f73de634abcdc36344cb72de36a (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')
-rw-r--r--drivers/net/gianfar.c5
-rw-r--r--drivers/net/gianfar.h3
-rw-r--r--drivers/net/gianfar_sysfs.c10
3 files changed, 12 insertions, 6 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 587afe7be689..6f22f068d6ee 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -138,6 +138,7 @@ static int gfar_poll(struct napi_struct *napi, int budget);
138static void gfar_netpoll(struct net_device *dev); 138static void gfar_netpoll(struct net_device *dev);
139#endif 139#endif
140int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit); 140int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
141static int gfar_clean_tx_ring(struct net_device *dev);
141static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length); 142static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length);
142static void gfar_vlan_rx_register(struct net_device *netdev, 143static void gfar_vlan_rx_register(struct net_device *netdev,
143 struct vlan_group *grp); 144 struct vlan_group *grp);
@@ -1141,7 +1142,7 @@ static int gfar_close(struct net_device *dev)
1141} 1142}
1142 1143
1143/* Changes the mac address if the controller is not running. */ 1144/* Changes the mac address if the controller is not running. */
1144int gfar_set_mac_address(struct net_device *dev) 1145static int gfar_set_mac_address(struct net_device *dev)
1145{ 1146{
1146 gfar_set_mac_for_addr(dev, 0, dev->dev_addr); 1147 gfar_set_mac_for_addr(dev, 0, dev->dev_addr);
1147 1148
@@ -1260,7 +1261,7 @@ static void gfar_timeout(struct net_device *dev)
1260} 1261}
1261 1262
1262/* Interrupt Handler for Transmit complete */ 1263/* Interrupt Handler for Transmit complete */
1263int gfar_clean_tx_ring(struct net_device *dev) 1264static int gfar_clean_tx_ring(struct net_device *dev)
1264{ 1265{
1265 struct txbd8 *bdp; 1266 struct txbd8 *bdp;
1266 struct gfar_private *priv = netdev_priv(dev); 1267 struct gfar_private *priv = netdev_priv(dev);
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index fd487be3993e..27f37c81e52c 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -782,5 +782,8 @@ extern void gfar_halt(struct net_device *dev);
782extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev, 782extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev,
783 int enable, u32 regnum, u32 read); 783 int enable, u32 regnum, u32 read);
784void gfar_init_sysfs(struct net_device *dev); 784void gfar_init_sysfs(struct net_device *dev);
785int gfar_local_mdio_write(struct gfar_mii __iomem *regs, int mii_id,
786 int regnum, u16 value);
787int gfar_local_mdio_read(struct gfar_mii __iomem *regs, int mii_id, int regnum);
785 788
786#endif /* __GIANFAR_H */ 789#endif /* __GIANFAR_H */
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
128out:
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
170out:
169 spin_unlock_irqrestore(&priv->rxlock, flags); 171 spin_unlock_irqrestore(&priv->rxlock, flags);
170 172
171 return count; 173 return count;