From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 703F0C4360C for ; Fri, 4 Oct 2019 06:23:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 42BF32133F for ; Fri, 4 Oct 2019 06:23:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731598AbfJDGXt (ORCPT ); Fri, 4 Oct 2019 02:23:49 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:34485 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729858AbfJDGXt (ORCPT ); Fri, 4 Oct 2019 02:23:49 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iGH08-0002b5-Iz; Fri, 04 Oct 2019 08:23:40 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iGH04-0005Rk-Dy; Fri, 04 Oct 2019 08:23:36 +0200 Date: Fri, 4 Oct 2019 08:23:36 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Yizhuo Cc: Fabrice Gasnier , Thierry Reding , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] pwm: stm32: Fix the usage of uninitialized variable in stm32_pwm_config() Message-ID: <20191004062336.jidzrytx4z5talro@pengutronix.de> References: <20191004044649.2405-1-yzhai003@ucr.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191004044649.2405-1-yzhai003@ucr.edu> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Thu, Oct 03, 2019 at 09:46:49PM -0700, Yizhuo wrote: > Inside function stm32_pwm_config(), variable "psc" and " arr" > could be uninitialized if regmap_read() returns -EINVALs. > However, they are used later in the if statement to decide > the return value which is potentially unsafe. > > The same case happens in function stm32_pwm_detect_channels() > with variable "ccer", but we cannot just return -EINVAL because > the error code is not acceptable by the caller. Aslo, the variable s/Aslo/Also/ > "ccer" in functionstm32_pwm_detect_complementary() could also be s/functionstm32_pwm_detect_/function stm32_pwm_detect_/ > uninitialized, since stm32_pwm_detect_complementary() returns void, > the patch is not easy. active_channels() is also affected. Also there are calls to regmap_update_bits which should have their return values checked. While a patch to fix these all is not trivial it is certainly possible and I would prefer to fix the problem completely. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |