From patchwork Fri Mar 4 14:09:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 12769168 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF815C433F5 for ; Fri, 4 Mar 2022 14:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=MVW0uP1edF6K46/gr0pf0WmCHnSJNEEdu/D2Xp9Yr2c=; b=WUVEkoQh9kpj6Y +X8Peacm50N5k7UUXF8GWRiGW4vj3qkw7977LLglkyOq2vIXFyJSCGGhXJtp7OF59YOFhDXHU5SjX xWM+u/9NNlMhiCvUhp7jSppXImF3t5I9k5u0ZnOypLOEu2iCkq4itUoSluQS8vlkMhRArK5PVHFe1 qfZWOhhQYK1ckqOOLHUNcFuPiJwGCaPDHjA7D6wwkwpitYDSFdOwCJsbvuUzfhHOv/ug+hih7HP/9 NnQmKcOyakRCu0eoUrsHKSDugOjijYU9EYDfN22h/ndN2hCnPKh9khhx+kkoTrx7OFbHRlmCx6oUr aterfI26IIB2hqKkqzvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQ8aZ-00APEy-0G; Fri, 04 Mar 2022 14:07:23 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQ8aU-00APE1-QD for linux-arm-kernel@lists.infradead.org; Fri, 04 Mar 2022 14:07:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1646402838; x=1677938838; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=h9w5rLlIgRL6Mreid8VITmayzPDrxYRkE0AGDM00690=; b=jCU8wgwiGrGNTstL0sDdGIjVFFLz/n3TDnIx0L9bnbJOt7/xMAR+hoI6 ZfEkN/RCErcdyGO5PaTZvQQeSBceG3knV/KYO5mb7XdHIXL5lJC5C4hYv MHNUqxNATqGe1CaPfoUvbCJO8GI5ZbXozabOxjTYzDrIuLoMjur8ED6+o DP6URGzlEvz4qGZdxaGg4Z+4TQc4YObs0riOI+Vulx6Hj1bxC/cfJDFx9 ogrHzip5Aij8k4J8cnknhlxrs4vwB6rhSeo2Ad0S/S3sRKVagZXfg3ON7 Qm8C/hhHNzyOIjf4YwpaxX4z1rCR6lxqQAOh8gKR41ixyDOfYWksXwAnZ Q==; X-IronPort-AV: E=Sophos;i="5.90,155,1643698800"; d="scan'208";a="155731531" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 04 Mar 2022 07:07:18 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Fri, 4 Mar 2022 07:07:17 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Fri, 4 Mar 2022 07:07:15 -0700 From: Horatiu Vultur To: , , , CC: , , , Horatiu Vultur Subject: [PATCH net-next] net: sparx5: Fix initialization of variables on stack Date: Fri, 4 Mar 2022 15:09:18 +0100 Message-ID: <20220304140918.3356873-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_060718_881052_F27FB40C X-CRM114-Status: GOOD ( 10.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The variables 'res' inside the functions sparx5_ptp_get_1ppm and sparx5_ptp_get_nominal_value was not initialized. So in case of the default case of the switch after, it would return an uninitialized variable. This makes also the clang builds to failed. Fixes: 0933bd04047c3b ("net: sparx5: Add support for ptp clocks") Signed-off-by: Horatiu Vultur --- drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c index fa377f6e7e08..cd110c31e5a4 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c @@ -32,7 +32,7 @@ static u64 sparx5_ptp_get_1ppm(struct sparx5 *sparx5) * (1/1000000)/((2^-59)/X) */ - u64 res; + u64 res = 0; switch (sparx5->coreclock) { case SPX5_CORE_CLOCK_250MHZ: @@ -54,7 +54,7 @@ static u64 sparx5_ptp_get_1ppm(struct sparx5 *sparx5) static u64 sparx5_ptp_get_nominal_value(struct sparx5 *sparx5) { - u64 res; + u64 res = 0; switch (sparx5->coreclock) { case SPX5_CORE_CLOCK_250MHZ: