aboutsummaryrefslogtreecommitdiffstats
path: root/net/ieee802154/wpan-class.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ieee802154/wpan-class.c')
-rw-r--r--net/ieee802154/wpan-class.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/ieee802154/wpan-class.c b/net/ieee802154/wpan-class.c
index 268691256a6d..1627ef2e8522 100644
--- a/net/ieee802154/wpan-class.c
+++ b/net/ieee802154/wpan-class.c
@@ -16,6 +16,7 @@
16 * 16 *
17 */ 17 */
18 18
19#include <linux/slab.h>
19#include <linux/kernel.h> 20#include <linux/kernel.h>
20#include <linux/module.h> 21#include <linux/module.h>
21#include <linux/device.h> 22#include <linux/device.h>
@@ -146,13 +147,15 @@ struct wpan_phy *wpan_phy_alloc(size_t priv_size)
146 struct wpan_phy *phy = kzalloc(sizeof(*phy) + priv_size, 147 struct wpan_phy *phy = kzalloc(sizeof(*phy) + priv_size,
147 GFP_KERNEL); 148 GFP_KERNEL);
148 149
150 if (!phy)
151 goto out;
149 mutex_lock(&wpan_phy_mutex); 152 mutex_lock(&wpan_phy_mutex);
150 phy->idx = wpan_phy_idx++; 153 phy->idx = wpan_phy_idx++;
151 if (unlikely(!wpan_phy_idx_valid(phy->idx))) { 154 if (unlikely(!wpan_phy_idx_valid(phy->idx))) {
152 wpan_phy_idx--; 155 wpan_phy_idx--;
153 mutex_unlock(&wpan_phy_mutex); 156 mutex_unlock(&wpan_phy_mutex);
154 kfree(phy); 157 kfree(phy);
155 return NULL; 158 goto out;
156 } 159 }
157 mutex_unlock(&wpan_phy_mutex); 160 mutex_unlock(&wpan_phy_mutex);
158 161
@@ -167,6 +170,9 @@ struct wpan_phy *wpan_phy_alloc(size_t priv_size)
167 phy->current_page = 0; /* for compatibility */ 170 phy->current_page = 0; /* for compatibility */
168 171
169 return phy; 172 return phy;
173
174out:
175 return NULL;
170} 176}
171EXPORT_SYMBOL(wpan_phy_alloc); 177EXPORT_SYMBOL(wpan_phy_alloc);
172 178