netfilter: qtaguid: Don't BUG_ON if create_if_tag_stat fails
authorPontus Fuchs <pontus.fuchs@gmail.com>
Mon, 19 Nov 2012 19:44:51 +0000 (11:44 -0800)
committerArve Hjønnevåg <arve@android.com>
Mon, 1 Jul 2013 21:16:14 +0000 (14:16 -0700)
If create_if_tag_stat fails to allocate memory (GFP_ATOMIC) the
following will happen:

qtaguid: iface_stat: tag stat alloc failed
...
kernel BUG at xt_qtaguid.c:1482!

Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com>
net/netfilter/xt_qtaguid.c

index 6b22563a924fe5386dc0d387121efd220bdf5d63..603bdd206990f3ed04bd7104a2f61b4c5a4977b6 100644 (file)
@@ -1461,6 +1461,8 @@ static void if_tag_stat_update(const char *ifname, uid_t uid,
                 *  - No {0, uid_tag} stats and no {acc_tag, uid_tag} stats.
                 */
                new_tag_stat = create_if_tag_stat(iface_entry, uid_tag);
+               if (!new_tag_stat)
+                       goto unlock;
                uid_tag_counters = &new_tag_stat->counters;
        } else {
                uid_tag_counters = &tag_stat_entry->counters;
@@ -1469,6 +1471,8 @@ static void if_tag_stat_update(const char *ifname, uid_t uid,
        if (acct_tag) {
                /* Create the child {acct_tag, uid_tag} and hook up parent. */
                new_tag_stat = create_if_tag_stat(iface_entry, tag);
+               if (!new_tag_stat)
+                       goto unlock;
                new_tag_stat->parent_counters = uid_tag_counters;
        } else {
                /*
@@ -1482,6 +1486,7 @@ static void if_tag_stat_update(const char *ifname, uid_t uid,
                BUG_ON(!new_tag_stat);
        }
        tag_stat_update(new_tag_stat, direction, proto, bytes);
+unlock:
        spin_unlock_bh(&iface_entry->tag_stat_list_lock);
 }