Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4088373rwb; Tue, 6 Sep 2022 02:15:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Aj6BYzimKaBja1LsjSAr8aiNO6Lwsx8E0yNJ6JXliyOL0qlxZwWD8IqjHQfHXqe7JFVjc X-Received: by 2002:a17:906:eeca:b0:730:6880:c397 with SMTP id wu10-20020a170906eeca00b007306880c397mr38211415ejb.593.1662455731710; Tue, 06 Sep 2022 02:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662455731; cv=none; d=google.com; s=arc-20160816; b=HQHCxWcOhAOwg74zF4FncFANTRTXoc62KeeVED7VXErzjC3bgbchcoA67rcGMcq85+ Q8xTVod7wjS5xxVKKxCCqFwZU9Qy5UVvDicjip/eS6frUUTcYRwDsrX27LV+lKW6N4MG o7qbi7Wh0q4/RfD+f8SzlIqUPc1yUoOPUWdw4bnZTPRw89fyzjCJCzj6mZlum7M/GeK2 L2ET2GqXkzX5edHtmmluI0or9BIo4a3KQUm+XE3n9C9l2wpxqbNLmXWWv2gRuqAa1pMv 8YBkyRFx3Si/Xx4ztwcsZot+4Lg1Q0vAfyEneAqRTkkv55pPVkTqqiS6rUy97GxYnH5H G4sw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oYZ9Wq3jM0aGkWOvYWKmVLjFLtLor/Gjf3AcMqCNWmU=; b=cgay/ZSTN0VJQI3Qj4ymtAKcL9DbGgOexUqiExF6Zvi4sPnUFQajIEh2MSsR8suuJD ByqkZpaPsUe/IJIB8/J42GZE5LtXoFaxN0WwEFJOZtxfMFIML44DKzstiSy2X9faWNGH YyOwjkiCY54MeNuZdkWwt/xiidDQC36sMIDVb9esoFKRPvgrfJgKsUoV3/C5NRdTwC+R Xe3pBLBV4a3Qc3QQBDJdpfqCO2Nw3ggFCy8IPQCIFb61fpcIesW47QCMvYYWAJ2i3K4B u7P0xz33nCbmiKnkq5UrTrMVF8howl73sPTkq4vfM82Xt+VYk3VYJiyELla+Jl1SYqo7 4Ycw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=VaYfNaSW; 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 gs13-20020a1709072d0d00b006feb76dbd51si9079510ejc.289.2022.09.06.02.15.06; Tue, 06 Sep 2022 02:15:31 -0700 (PDT) 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=VaYfNaSW; 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 S239004AbiIFIfH (ORCPT + 99 others); Tue, 6 Sep 2022 04:35:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234243AbiIFIeu (ORCPT ); Tue, 6 Sep 2022 04:34:50 -0400 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 562A722B10; Tue, 6 Sep 2022 01:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1662453288; x=1693989288; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oYZ9Wq3jM0aGkWOvYWKmVLjFLtLor/Gjf3AcMqCNWmU=; b=VaYfNaSW+iTQZ1muZmtHyTxKPvNyJdUTJkdoiE0PuNgnGtABhRJZq55j pi6g17SZKzxm0p7ye85cz1UraaMjQJs83+NiuZ+J3kp0xeapgniD69OIW OPnndjXW0d+lGiASm2vTU1gXtNI5gwkZ/f4iBXQHC9qLWBK7XgVHbX3Oj o=; X-IronPort-AV: E=Sophos;i="5.93,293,1654560000"; d="scan'208";a="241387515" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-b48bc93b.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 08:34:40 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1d-b48bc93b.us-east-1.amazon.com (Postfix) with ESMTPS id 88852C022E; Tue, 6 Sep 2022 08:34:38 +0000 (UTC) Received: from EX19D013UWA001.ant.amazon.com (10.13.138.253) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 6 Sep 2022 08:34:00 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX19D013UWA001.ant.amazon.com (10.13.138.253) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Tue, 6 Sep 2022 08:33:59 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1497.38 via Frontend Transport; Tue, 6 Sep 2022 08:33:59 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id D26DC4D79; Tue, 6 Sep 2022 08:33:56 +0000 (UTC) From: Eliav Farber To: , , , , , , , CC: , , , Subject: [PATCH v4 03/21] hwmon: (mr75203) fix VM sensor allocation when "intel,vm-map" not defined Date: Tue, 6 Sep 2022 08:33:38 +0000 Message-ID: <20220906083356.21067-4-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220906083356.21067-1-farbere@amazon.com> References: <20220906083356.21067-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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,T_SCC_BODY_TEXT_LINE, 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 Bug - in case "intel,vm-map" is missing in device-tree ,'num' is set to 0, and no voltage channel infos are allocated. The reason num is set to 0 when "intel,vm-map" is missing is to set the entire pvt->vm_idx[] with incremental channel numbers, but it didn't take into consideration that same num is used later in devm_kcalloc(). If "intel,vm-map" does exist there is no need to set the unspecified channels with incremental numbers, because the unspecified channels can't be accessed in pvt_read_in() which is the only other place besides the probe functions that uses pvt->vm_idx[]. This change fixes the bug by moving the incremental channel numbers setting to be done only if "intel,vm-map" property is defined (starting loop from 0), and removing 'num = 0'. Fixes: 9d823351a337 ("hwmon: Add hardware monitoring driver for Moortec MR75203 PVT controller") Signed-off-by: Eliav Farber --- V4 -> v3: - Simplify the fix by not removing the local num variable (it is removed as part of a later commit). drivers/hwmon/mr75203.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c index 8adfbb15453f..0ead576694a1 100644 --- a/drivers/hwmon/mr75203.c +++ b/drivers/hwmon/mr75203.c @@ -594,7 +594,12 @@ static int mr75203_probe(struct platform_device *pdev) ret = device_property_read_u8_array(dev, "intel,vm-map", pvt->vm_idx, vm_num); if (ret) { - num = 0; + /* + * Incase intel,vm-map property is not defined, we + * assume incremental channel numbers. + */ + for (i = 0; i < vm_num; i++) + pvt->vm_idx[i] = i; } else { for (i = 0; i < vm_num; i++) if (pvt->vm_idx[i] >= vm_num || @@ -604,13 +609,6 @@ static int mr75203_probe(struct platform_device *pdev) } } - /* - * Incase intel,vm-map property is not defined, we assume - * incremental channel numbers. - */ - for (i = num; i < vm_num; i++) - pvt->vm_idx[i] = i; - in_config = devm_kcalloc(dev, num + 1, sizeof(*in_config), GFP_KERNEL); if (!in_config) -- 2.37.1