diff options
author | Denis Kirjanov <dkirjanov@hera.kernel.org> | 2010-05-23 07:45:45 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-24 08:11:07 +0200 |
commit | a6c0f8217c17d46da22fa56923f3cbd03615cb7c (patch) | |
tree | 32eacbe6529f885b858cd39e70b6b989eb090f88 /net/ieee802154 | |
parent | enic: Use random mac addr when associating port-profile (diff) | |
download | linux-a6c0f8217c17d46da22fa56923f3cbd03615cb7c.tar.xz linux-a6c0f8217c17d46da22fa56923f3cbd03615cb7c.zip |
ieee802154: Fix possible NULL pointer dereference in wpan_phy_alloc
Check for NULL pointer after kzalloc
Signed-off-by: Denis Kirjanov <dkirjanov@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ieee802154')
-rw-r--r-- | net/ieee802154/wpan-class.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/ieee802154/wpan-class.c b/net/ieee802154/wpan-class.c index 3d803a1b9fb6..1627ef2e8522 100644 --- a/net/ieee802154/wpan-class.c +++ b/net/ieee802154/wpan-class.c @@ -147,13 +147,15 @@ struct wpan_phy *wpan_phy_alloc(size_t priv_size) struct wpan_phy *phy = kzalloc(sizeof(*phy) + priv_size, GFP_KERNEL); + if (!phy) + goto out; mutex_lock(&wpan_phy_mutex); phy->idx = wpan_phy_idx++; if (unlikely(!wpan_phy_idx_valid(phy->idx))) { wpan_phy_idx--; mutex_unlock(&wpan_phy_mutex); kfree(phy); - return NULL; + goto out; } mutex_unlock(&wpan_phy_mutex); @@ -168,6 +170,9 @@ struct wpan_phy *wpan_phy_alloc(size_t priv_size) phy->current_page = 0; /* for compatibility */ return phy; + +out: + return NULL; } EXPORT_SYMBOL(wpan_phy_alloc); |