From patchwork Sun Feb 26 01:37:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Munehisa Kamata X-Patchwork-Id: 61545 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1746791wrd; Sat, 25 Feb 2023 17:52:35 -0800 (PST) X-Google-Smtp-Source: AK7set8exK0o1RTpiGprOs34HpHdMlhNOVmWPk2FN6oPKFL2u2ygXLwMCgMQKuTeIOl5gMgXYMBx X-Received: by 2002:a05:6402:3813:b0:4af:7bdc:188e with SMTP id es19-20020a056402381300b004af7bdc188emr3836389edb.16.1677376355313; Sat, 25 Feb 2023 17:52:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677376355; cv=none; d=google.com; s=arc-20160816; b=FxGFRGTdupE6RrYpEuRrOTigwUAc/0cTCWVyIzWfS30w/58PMvPTiByB6EJBUOmOzY Xti3VeAnFWFkBGqxiTmHshi1n0vpky2fYvfRDzMy0A1esqLGHvtZpvrwazP68M3DiKHD /Ny3gNIQoXlDztmtaZc9wrNiXlz1uNt1knL55TTX4LkmJNe+yo+k2cn+Aa45iccAtrL7 719xD1U6F15wXJKbqAijd4fO/HGzwgneCufTQfDb6PyVyr2afn/u7Ngmfbl5IBnSMdQr vCVTBldEcgt9oVK2RhyHTxUZOH0/cGlT9P6FhK//hZJu9ZqHlk9DxSZ/s4BFYHDvDyeY pQBA== 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=VN9+lKpIv8OFPEcx6C6zFpPockwjmo2bbc4mI4drChU=; b=ITMMza7V58nvtzptjQsJ2h7n1tJgTgrmbLW96tJ6OnaCBDp16OHdWhCsXsVfT/StlI umG+INo+vBi3LZxA5HwzvmPiKjALdIfJSn1A/ApUwmxvunqCo7HPQRGGjAuV/KBInl30 aU1se6TQnqU54YaLi6bVgrqxUL+ly4gVSIAOjHPuXIt6Ftd6jKq3QK9qyVCAzjilXv4m g4zpXPt7vCHdwiYFweYhaaBDSaOQpKsPi0sjrYV4v59oNeqgYoYgAhZm5P59TtlZc8fX shgdmmu3HU1ETlSnzDh6b44lEf+x4ekws0M1MiOfqG5zP3QcbfZBUOv04kdEiTQhaOj6 aY+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b="agMyv5n/"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020aa7d886000000b004accb663177si4126118edq.330.2023.02.25.17.52.04; Sat, 25 Feb 2023 17:52:35 -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="agMyv5n/"; 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 S229523AbjBZBhk (ORCPT + 99 others); Sat, 25 Feb 2023 20:37:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjBZBhj (ORCPT ); Sat, 25 Feb 2023 20:37:39 -0500 Received: from smtp-fw-6001.amazon.com (smtp-fw-6001.amazon.com [52.95.48.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 727EB11EA1; Sat, 25 Feb 2023 17:37:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1677375458; x=1708911458; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=VN9+lKpIv8OFPEcx6C6zFpPockwjmo2bbc4mI4drChU=; b=agMyv5n/xH0t7jZeTsPah1ijEaVIrVNbDVyS15RkowlqX7z5QGYjcU3N 8429CVCwSXf+LP0FTqIprH63V2Ypqw/ztdFN2PfvbbtXP2IKzmG5BsLLJ ApvWSEiSn/JatbzLWXnRIQonJ6/cNhnIpCw7szXtQlfkBNSg2g8QEmH2H s=; X-IronPort-AV: E=Sophos;i="5.97,328,1669075200"; d="scan'208";a="303015007" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-pdx-2b-m6i4x-cadc3fbd.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-6001.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2023 01:37:37 +0000 Received: from EX13MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2b-m6i4x-cadc3fbd.us-west-2.amazon.com (Postfix) with ESMTPS id C71F7A2992; Sun, 26 Feb 2023 01:37:35 +0000 (UTC) Received: from EX19D010UWA004.ant.amazon.com (10.13.138.204) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.45; Sun, 26 Feb 2023 01:37:34 +0000 Received: from u9aa42af9e4c55a.ant.amazon.com (10.106.100.27) by EX19D010UWA004.ant.amazon.com (10.13.138.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.24; Sun, 26 Feb 2023 01:37:34 +0000 From: Munehisa Kamata To: CC: , , , , Munehisa Kamata , Subject: [PATCH] pwm: core: Zero-initialize the temp state Date: Sat, 25 Feb 2023 17:37:21 -0800 Message-ID: <20230226013722.1802842-1-kamatam@amazon.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.106.100.27] X-ClientProxiedBy: EX19D031UWC003.ant.amazon.com (10.13.139.252) To EX19D010UWA004.ant.amazon.com (10.13.138.204) 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758856589160122907?= X-GMAIL-MSGID: =?utf-8?q?1758856589160122907?= Zero-initialize the on-stack structure to avoid unexpected behaviors. Some drivers may not set or initialize all the values in pwm_state through their .get_state() callback and therefore some random values may remain there and be set into pwm->state eventually. This actually caused regression on ODROID-N2+ as reported in [1]; kernel fails to boot due to random panic or hang-up. [1] https://forum.odroid.com/viewtopic.php?f=177&t=46360 Fixes: c73a3107624d ("pwm: Handle .get_state() failures") Cc: stable@vger.kernel.org # 6.2 Signed-off-by: Munehisa Kamata --- drivers/pwm/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index e01147f66e15..6eac8022a2c2 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -117,6 +117,7 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label) if (pwm->chip->ops->get_state) { struct pwm_state state; + memset(&state, 0, sizeof(struct pwm_state)); err = pwm->chip->ops->get_state(pwm->chip, pwm, &state); trace_pwm_get(pwm, &state, err);