Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp595682pxp; Sat, 5 Mar 2022 12:29:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlZNQkTA/A8a+sx7T3sGKaTvNfttErlGum1n6j4NsW4vL/LxqoZcCnbz5SUpT3a2ZwefI+ X-Received: by 2002:a63:9143:0:b0:37c:ed47:3d28 with SMTP id l64-20020a639143000000b0037ced473d28mr3908797pge.193.1646512178253; Sat, 05 Mar 2022 12:29:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646512178; cv=none; d=google.com; s=arc-20160816; b=Azmpnqd0VznrFZLmzJ9ltCmXg5lDxwTZqB1uX3J0P7Fs3tKdnTlfLe0eVVHMFnlaon 61AxHJtVlBJXIEXAFkpn160tNAe+2maBm3l22A267Clwl81QlE/LoeS3fbyJ5pW39hX/ W6uKwDho5FXWZimwTWDTQmadAMCqzS/5FKQKlB/n7qfuQ/ofC5QDVcB+DCgZMN8ihvsA SySs5Pgbn/wdugYvzHZBcoNfq6lGt6RTEEk2knnEAzBhmIorAnmKH+oxyGl62XP6P3If +0G0fAA1HBRXVKn8qWRLvu04FGODJVWGtaJx2gX9aduFg4xY7FhQX0AnLG0xbsKC2J1D fosA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=TQ/PmDy/wAuYSRhPMWBzjgjzADBCIpXP0+QPOpZXWOA=; b=uyUayacoicZ++fituiRLeqtWiotoAxOARzxQeKe+xJJnlLqXf36/3WcVibl4BmQj01 PUDr3F6UgZ1vLDAVSyWXF/Wkk5uMNUol8oG5gWe2B8EDYDf7nfcY/vTf1HUqD1Y/D1rz gqym4CznLUNEb9Wk5RtMJ7hrF654Cqg1TR0w3sVkoPohkSPgOLYEtxppGafuq9nNVYFJ l9NpiNTwHO7Boc8sATpyP6o3tslID+258vcoALbdETXd2SGge04Rywn2anQPeywlH+/v LG2svRrVNlYAjyHEmAORvCU7+SnWDCgim9iOnjouwwuAq5+3C2hmLXZSXA+EwrDkIIf4 3fTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eVjd5BSA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a17090341cd00b0014a83b6ace0si8715277ple.463.2022.03.05.12.29.15; Sat, 05 Mar 2022 12:29:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eVjd5BSA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232157AbiCESOv (ORCPT + 99 others); Sat, 5 Mar 2022 13:14:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbiCESOu (ORCPT ); Sat, 5 Mar 2022 13:14:50 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A03F16D3B7 for ; Sat, 5 Mar 2022 10:13:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646504038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=TQ/PmDy/wAuYSRhPMWBzjgjzADBCIpXP0+QPOpZXWOA=; b=eVjd5BSAJH9jYsSmtF05zs+ORjkg1vq6jSrLqK60ml/tUERZS1ZXWk0B7fbbgXwzx7xcKG qpS3wLk0ADZu/5kSv8+Pw2DoU2SP0wG5WPKbB9TW18G94lGW6ZXuaB8hbXOmrEdjjDWqLT ATjV8qesdDIscb46ufESL4croK9jzrs= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-580-KvaqVP3fPHmw5T3-Uyfvww-1; Sat, 05 Mar 2022 13:13:57 -0500 X-MC-Unique: KvaqVP3fPHmw5T3-Uyfvww-1 Received: by mail-qk1-f199.google.com with SMTP id 134-20020a37088c000000b0067af418b2f1so1250085qki.16 for ; Sat, 05 Mar 2022 10:13:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TQ/PmDy/wAuYSRhPMWBzjgjzADBCIpXP0+QPOpZXWOA=; b=GcK5Ug6/beiLFcrUGmgv63TnnNqrjB9lvG2ayWk6ds0/lJEJkeRwlFaRRXsL49iqnu +EyAF+nt/Rjdy2l/ChzFvN4Xn2M5pPlsrDuaDJjLqdCJ9pD0M5QpY7/fAUv0ufX3tOq0 DToeL3yKr87CzqxTpC+KHQcXKhjDTxSUydAkQ7LJjQ83MMVL5/ZBPWFcM5CMUv6i7BEu 82kHO+0OHMiT2BUPkwjYHhv3l/d0hoxBM1aHo0tRhwke4vswC2LRTRS+aYMBAWxZ5Faj /qSvoOFPD6V35y94kA5Qz2yXk74XAA71Isuz5IqWQ0E0p5NzsmQ0Ml+bOzDzXLfaZxE0 S7Vw== X-Gm-Message-State: AOAM531QS1vu+ib1AntPw8TtBjWxt+smH9wxRJfTWFw1Zn//Nl+eAXA0 N15psHV3g8UR5WKqyN44wmzZXurDS0JIMSqASCAV6KgesNa5Y+WfYlsV0pyMPbrFMhfE1cIFHkh YCj/3u5UhcO7cBMAeeUEVq1Dl X-Received: by 2002:a37:55c2:0:b0:479:8293:d7d0 with SMTP id j185-20020a3755c2000000b004798293d7d0mr2560814qkb.182.1646504036865; Sat, 05 Mar 2022 10:13:56 -0800 (PST) X-Received: by 2002:a37:55c2:0:b0:479:8293:d7d0 with SMTP id j185-20020a3755c2000000b004798293d7d0mr2560793qkb.182.1646504036653; Sat, 05 Mar 2022 10:13:56 -0800 (PST) Received: from localhost.localdomain.com (024-205-208-113.res.spectrum.com. [24.205.208.113]) by smtp.gmail.com with ESMTPSA id w20-20020a05622a135400b002dd9806d532sm5376407qtk.54.2022.03.05.10.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Mar 2022 10:13:56 -0800 (PST) From: trix@redhat.com To: davem@davemloft.net, kuba@kernel.org, nathan@kernel.org, ndesaulniers@google.com, idosch@nvidia.com, petrm@nvidia.com, edumazet@google.com, avagin@gmail.com, yajun.deng@linux.dev, johannes.berg@intel.com, cong.wang@bytedance.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Tom Rix Subject: [PATCH] net: rtnetlink: fix error handling in rtnl_fill_statsinfo() Date: Sat, 5 Mar 2022 10:13:46 -0800 Message-Id: <20220305181346.697365-1-trix@redhat.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Rix The clang static analyzer reports this issue rtnetlink.c:5481:2: warning: Undefined or garbage value returned to caller return err; ^~~~~~~~~~ There is a function level err variable, in the list_for_each_entry_rcu block there is a shadow err. Remove the shadow. In the same block, the call to nla_nest_start_noflag() can fail without setting an err. Set the err to -EMSGSIZE. Fixes: 216e690631f5 ("net: rtnetlink: rtnl_fill_statsinfo(): Permit non-EMSGSIZE error returns") Signed-off-by: Tom Rix --- net/core/rtnetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index a66b6761b88b1..a759f9e0a8476 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -5440,12 +5440,12 @@ static int rtnl_fill_statsinfo(struct sk_buff *skb, struct net_device *dev, list_for_each_entry_rcu(af_ops, &rtnl_af_ops, list) { if (af_ops->fill_stats_af) { struct nlattr *af; - int err; af = nla_nest_start_noflag(skb, af_ops->family); if (!af) { rcu_read_unlock(); + err = -EMSGSIZE; goto nla_put_failure; } err = af_ops->fill_stats_af(skb, dev); -- 2.26.3