From patchwork Sat Sep 22 02:10:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11630 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C879823EFC for ; Sat, 22 Sep 2012 02:11:11 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8CCE5A1831B for ; Sat, 22 Sep 2012 02:11:11 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so6323403iej.11 for ; Fri, 21 Sep 2012 19:11:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references:x-cbid :x-gm-message-state; bh=yQwz3Ct36H3OMyZgqQ+uMIjhYWTs2EYFxjRq1HdE3VE=; b=ItJd197rl4UrulX3+vshlxw06KhLZibS5Wg1+i0BUZddRpA9LmwuSIb1u7bDmUVN8o mhxEKHAnVklzWNP21iIyFhcPDliFpoXGPN2TUt2KAqI/Gcxho1JdmGwozVneECJHDfVL uzHaewn3oi2elNI+est84uz0nrbT91qVkf2QDa5aQz0suMGxPC5sICAt/o5Xjgfb1YCa 2jqnIcXsKHaiS6FW8b11QHmAXHzIfpdH3mJ718/CgAUlt4cgw27BNg/ysvbOVX1/CjSl y7q1UV7WG39cINJ+61KJU67lGc0dUGmsbOT9L7xX+ILArppzp4wVY26Qiv0KJzlhk2nX n3kg== Received: by 10.50.0.193 with SMTP id 1mr168964igg.0.1348279871357; Fri, 21 Sep 2012 19:11:11 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp157907igc; Fri, 21 Sep 2012 19:11:10 -0700 (PDT) Received: by 10.50.192.234 with SMTP id hj10mr109513igc.53.1348279870374; Fri, 21 Sep 2012 19:11:10 -0700 (PDT) Received: from e9.ny.us.ibm.com (e9.ny.us.ibm.com. [32.97.182.139]) by mx.google.com with ESMTPS id e1si12384766ict.29.2012.09.21.19.11.10 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Sep 2012 19:11:10 -0700 (PDT) Received-SPF: neutral (google.com: 32.97.182.139 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=32.97.182.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 32.97.182.139 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 21 Sep 2012 22:11:09 -0400 Received: from d01relay04.pok.ibm.com (9.56.227.236) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 21 Sep 2012 22:11:06 -0400 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8M2B5kP136332; Fri, 21 Sep 2012 22:11:05 -0400 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8M2B4qh001388; Fri, 21 Sep 2012 20:11:05 -0600 Received: from kernel-pok.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q8M2B1P7001183; Fri, 21 Sep 2012 20:11:04 -0600 From: John Stultz To: LKML Cc: JP Abgrall , netdev@vger.kernel.org, Ashish Sharma , Peter P Waskiewicz Jr , John Stultz Subject: [PATCH 3/7][RFC] netfilter: qtaguid: initialize a local var to keep compiler happy. Date: Fri, 21 Sep 2012 22:10:49 -0400 Message-Id: <1348279853-44499-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348279853-44499-1-git-send-email-john.stultz@linaro.org> References: <1348279853-44499-1-git-send-email-john.stultz@linaro.org> x-cbid: 12092202-7182-0000-0000-000002ACD8DE X-Gm-Message-State: ALoCoQmDqz35dHHEpb8cYyvA9HAASDNwKlaDXv9HbhcYYYqdRHwSEReMUaQxQuTzTviDpmHxGfos From: JP Abgrall There was a case that might have seemed like new_tag_stat was not initialized and actually used. Added comment explaining why it was impossible, and a BUG() in case the logic gets changed. Cc: netdev@vger.kernel.org Cc: JP Abgrall Cc: Ashish Sharma Cc: Peter P Waskiewicz Jr Signed-off-by: JP Abgrall Signed-off-by: John Stultz --- net/netfilter/xt_qtaguid.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/netfilter/xt_qtaguid.c b/net/netfilter/xt_qtaguid.c index 7c4ac46..214a990 100644 --- a/net/netfilter/xt_qtaguid.c +++ b/net/netfilter/xt_qtaguid.c @@ -1255,7 +1255,7 @@ static void if_tag_stat_update(const char *ifname, uid_t uid, struct data_counters *uid_tag_counters; struct sock_tag *sock_tag_entry; struct iface_stat *iface_entry; - struct tag_stat *new_tag_stat; + struct tag_stat *new_tag_stat = NULL; MT_DEBUG("qtaguid: if_tag_stat_update(ifname=%s " "uid=%u sk=%p dir=%d proto=%d bytes=%d)\n", ifname, uid, sk, direction, proto, bytes); @@ -1320,8 +1320,19 @@ 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); new_tag_stat->parent_counters = uid_tag_counters; + } else { + /* + * For new_tag_stat to be still NULL here would require: + * {0, uid_tag} exists + * and {acct_tag, uid_tag} doesn't exist + * AND acct_tag == 0. + * Impossible. This reassures us that new_tag_stat + * below will always be assigned. + */ + BUG_ON(!new_tag_stat); } tag_stat_update(new_tag_stat, direction, proto, bytes); spin_unlock_bh(&iface_entry->tag_stat_list_lock);