Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8143829rwl; Tue, 10 Jan 2023 09:31:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9OJm/94hK7Bq/nDy9t+9kbvqudTrzxe6ylGWANKI1YTjDFiy8vfQdOox4rqqy4ldvfTVN X-Received: by 2002:a17:907:c30a:b0:7c1:18b1:fd93 with SMTP id tl10-20020a170907c30a00b007c118b1fd93mr63513395ejc.44.1673371905956; Tue, 10 Jan 2023 09:31:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673371905; cv=none; d=google.com; s=arc-20160816; b=vqsi4RtL1N2JRvKnOOLSyZm7dBmi7bUhzf6LVp9z04hc+jypQLtZiwiDnCxxXixcHZ Gfb7PY1pgjGcaQC6v8wut+aqQbeCxtUkbAEoeTKgzBZvrBkPZCgGcRyGrX7T6wHoNgM8 kOLsmOuBzdCXL4C3LGXmWHCG+n14cqbPQWYtYmzHCyT7Pe7Q5znvGcWGYUecGg3cauUO mNaeSajo82hPqyz+Jhajcg5ist93AdyRVZmJqDFvCGOH1jiXBQAYV9hgvH/RJAn1MMJe dVnDuiMSB7BJzOnYAtmoKfOEKFCfI1zLOWoY51UPFEVvbxwysLzd/OJdjy40MZOAKJjq 7v7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date:subject :cc:to:from:user-agent:references:dkim-signature; bh=v0FHnqz++7WAyCUdZ4a39D9ZNS9Mj+/iD1X/Rx7tWI4=; b=1H7Xsd/MrhBfwtsLJdJh/VRPqKzUhpXHniHJsRIy1cizqOquh1o9aqNKZGwfSBupJR abFTiX2KEfxeNp20AtcY3rkH8VROYIQUuUUTbuqxovaD5m3+CNE6gX+Qt2kvUb3pKUVW Cfb4Y2+BSkfn1GACjkMTycCtweWuYKs8YmBaTr1u14pXFuqbwFH+jL+zEndVep/fFA0G LIyvyIwB81B3hxG72CXTSCVU4sT8BkPCiEkO7nQzZKuUUE/2+KlYOW3HJs6IZ1cjEKF6 Br+Qv5rfgtdRTLoqRjLUzOoU9N/XNedYA3WUB+EL4JMW2Z9+yDR1n85pwGe5BqW5s7uO Knzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=hOSplJKN; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a17090658c600b007a953d421bbsi13598643ejs.322.2023.01.10.09.31.32; Tue, 10 Jan 2023 09:31:45 -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=@amazon.com header.s=amazon201209 header.b=hOSplJKN; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232356AbjAJRAD (ORCPT + 53 others); Tue, 10 Jan 2023 12:00:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232003AbjAJRAA (ORCPT ); Tue, 10 Jan 2023 12:00:00 -0500 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E14A380; Tue, 10 Jan 2023 08:59:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1673370000; x=1704906000; h=references:from:to:cc:subject:date:in-reply-to: message-id:mime-version; bh=v0FHnqz++7WAyCUdZ4a39D9ZNS9Mj+/iD1X/Rx7tWI4=; b=hOSplJKNcnwv7w8M77WMlrFQXDw/P49OpFHcgkmX0OiGLuoGFvCo1Q2T WeEkScKgEccpX538NKE2xFObQt7EiLzl2LhmwlloPHIl+ZDRqxsY+ug62 qx9/LmmIaJ41fRXlofc0/ff5CQGjyZbQ9QDeVqNw0/ib0bSSuqo6tNIWt s=; X-IronPort-AV: E=Sophos;i="5.96,315,1665446400"; d="scan'208";a="285208024" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2b-m6i4x-189d700f.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2023 16:59:53 +0000 Received: from EX13D48EUB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2b-m6i4x-189d700f.us-west-2.amazon.com (Postfix) with ESMTPS id 6920741664; Tue, 10 Jan 2023 16:59:51 +0000 (UTC) Received: from EX19D028EUB003.ant.amazon.com (10.252.61.31) by EX13D48EUB001.ant.amazon.com (10.43.166.179) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 10 Jan 2023 16:59:50 +0000 Received: from u570694869fb251.ant.amazon.com.amazon.com (10.43.160.120) by EX19D028EUB003.ant.amazon.com (10.252.61.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.7; Tue, 10 Jan 2023 16:59:40 +0000 References: <20230108143843.2987732-1-trix@redhat.com> User-agent: mu4e 1.6.10; emacs 28.0.91 From: Shay Agroskin To: Eric Dumazet CC: Tom Rix , , , , , , , , , , , , , , <42.hyeyoo@gmail.com>, , , Subject: Re: [PATCH] net: ena: initialize dim_sample Date: Tue, 10 Jan 2023 18:58:37 +0200 In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Originating-IP: [10.43.160.120] X-ClientProxiedBy: EX13D45UWA002.ant.amazon.com (10.43.160.38) To EX19D028EUB003.ant.amazon.com (10.252.61.31) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_SPF_WL 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 Eric Dumazet writes: > On Sun, Jan 8, 2023 at 3:38 PM Tom Rix wrote: >> >> clang static analysis reports this problem >> drivers/net/ethernet/amazon/ena/ena_netdev.c:1821:2: warning: >> Passed-by-value struct >> argument contains uninitialized data (e.g., field: >> 'comp_ctr') [core.CallAndMessage] >> net_dim(&ena_napi->dim, dim_sample); >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> >> net_dim can call dim_calc_stats() which uses the comp_ctr >> element, >> so it must be initialized. > > This seems to be a dim_update_sample() problem really, when > comp_ctr > has been added... > > Your patch works, but we could avoid pre-initializing dim_sample > in all callers, > then re-writing all but one field... > > diff --git a/include/linux/dim.h b/include/linux/dim.h > index > 6c5733981563eadf5f06c59c5dc97df961692b02..4604ced4517268ef8912cd8053ac8f4d2630f977 > 100644 > --- a/include/linux/dim.h > +++ b/include/linux/dim.h > @@ -254,6 +254,7 @@ dim_update_sample(u16 event_ctr, u64 > packets, u64 > bytes, struct dim_sample *s) > s->pkt_ctr = packets; > s->byte_ctr = bytes; > s->event_ctr = event_ctr; > + s->comp_ctr = 0; > } > > /** Hi, I'd rather go with Eric's solution to this issue than zero the whole struct in ENA Thanks, Shay