Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp490273ybm; Thu, 28 May 2020 07:56:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaGQbv3EGseQe2JZYOFuV1aw87nfP5lMnmWccgdyEhjLs0UcAa7RidoDyrMIa2LqH4YXxv X-Received: by 2002:a17:906:c943:: with SMTP id fw3mr3285422ejb.288.1590677766693; Thu, 28 May 2020 07:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590677766; cv=none; d=google.com; s=arc-20160816; b=dZlb0XMQU4llQV7kAKbeL2ph1MnmzVrnyq3iWFYBbAosG5Bod5k4QuwgI9J3xxET7a 6/vg3Sds2PCzmL0NJQLi0jizj4kFffAFullP9L1rLj0Wasff90TlLevCQpfwI2lIh7CO 9T/Ij/USH8y1l5g2jq0WoEr0UmQ1Mp8jaKB9vbFOtOfzIhJuk8CP/9F0HyC9bhMPCTRp kknmH6Mdi6KvllGqhM/+SRO88d7U+SbFwjCgGnr0FKg6dumGpGmQ5tQ0R7dzr4913K1f Vj8yTHy3BTt4sgAxenYasGTYKdamStXR69W6GZO+pZL2ItMc2kI1PG0uFhX45PV2K2X4 94ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=/nnTDcDZgdfyy1FWW65Kj2LhRtlRh4X2KgqGO4Hf6qU=; b=S/ss5yiAFNNR21+5PbQqVzQK7HKODn4tGJCNsI/2I9r6EGEiYXjlOLqEeEw0y81g+w njtfBXFFNJRyCdZL6sIrPunvz9KA4O3Lyg5dXdO98VhLb8J/QhpxwC0CZ/pevp/57q9C zLcpA0vCzO/EyfCX3qfRVuCiB53WAn4tWUcqiJCGcPyxFJuhBO1mQY2AlBNLROwGo845 Ns3G3G8lS7Jwjs/fJWwXho8BT2iCfRz5GKCgfAzzmRsL5Hp495lWCGmKMa1BP0RZH4pQ K3C7k0nfYkfKVIOjx67oYQGwgQLEIWKvpuHXZ4funO7O2H4ZUrWmlp6NMQQdkf+27MOA WPLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e21si3989544ejr.504.2020.05.28.07.55.43; Thu, 28 May 2020 07:56:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403780AbgE1Ova (ORCPT + 99 others); Thu, 28 May 2020 10:51:30 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57847 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728648AbgE1OvY (ORCPT ); Thu, 28 May 2020 10:51:24 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jeJsI-0006B0-7R; Thu, 28 May 2020 14:51:14 +0000 From: Colin King To: David Ahern , "David S . Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Jakub Kicinski , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][net-next] nexthop: fix incorrect allocation failure on nhg->spare Date: Thu, 28 May 2020 15:51:14 +0100 Message-Id: <20200528145114.420100-1-colin.king@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The allocation failure check for nhg->spare is currently checking the pointer nhg rather than nhg->spare which is never false. Fix this by checking nhg->spare instead. Addresses-Coverity: ("Logically dead code") Fixes: 430a049190de ("nexthop: Add support for nexthop groups") Signed-off-by: Colin Ian King --- net/ipv4/nexthop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index ebafa5ed91ac..97423d6f2de9 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -1185,7 +1185,7 @@ static struct nexthop *nexthop_create_group(struct net *net, /* spare group used for removals */ nhg->spare = nexthop_grp_alloc(num_nh); - if (!nhg) { + if (!nhg->spare) { kfree(nhg); kfree(nh); return NULL; -- 2.25.1