From patchwork Wed Jul 25 07:38:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 10543649 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DFBA14BC for ; Wed, 25 Jul 2018 07:38:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AB61295EE for ; Wed, 25 Jul 2018 07:38:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E9E529601; Wed, 25 Jul 2018 07:38:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E59A5295EE for ; Wed, 25 Jul 2018 07:38:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C78F26E1FD; Wed, 25 Jul 2018 07:38:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id A62416E382 for ; Wed, 25 Jul 2018 07:38:39 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id s14-v6so4951523wmc.1 for ; Wed, 25 Jul 2018 00:38:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cSt1pwQsxGzBw3uquJPq4af2a8gX01/8NUMRtpKzH84=; b=kw+02GYnNJ6fYOAPD4/9bK2NnOuuJM/f2btKwTCLozJdk6wGE2l+sR9WUv7EyUU7rA LCo1ge8kR+OTj4PPBJ2JONqhHM3ezqvqkI2fPF9p2WOwJKKBaAFL3ibxbYKMO0eBXlEr pGvrH2tmdn28aLz4gu1VkP62q9/jVoRkrD9QLlub1Wcx7/ZYIagcKpaGW9cDeRlzktuH xVCL/eNNuPIaoW6vMCiYdm1kOZ8d1GkAQehNA4ymjEGizEFnAF/R5OVzrd5VEQUnGEKh rBDgUIRZm+Ccd7KMx6ALGJoSGyUYKo6M7+aE9IdFgGCf9Nlfmy9Li+VmSDqz0ATXMovU i+Ng== X-Gm-Message-State: AOUpUlGggiv2CfmrKWXniVDJScKDpFL1wh3cMeNGW1YJ+5tRx7iT8STS BKBK9VkU1Fgb5QxcitXGfZLRvw== X-Google-Smtp-Source: AAOMgpdJmDFN1yo6ugml6NGoyoPnSjZ0Zge8XeT8R33erBCUa3bzorJIIIJfXN5a2aFc5ttwCbGhTw== X-Received: by 2002:a1c:8406:: with SMTP id g6-v6mr3666024wmd.18.1532504318356; Wed, 25 Jul 2018 00:38:38 -0700 (PDT) Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id h7-v6sm10243795wrs.8.2018.07.25.00.38.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jul 2018 00:38:37 -0700 (PDT) From: Daniel Thompson To: Lee Jones , Daniel Thompson , Jingoo Han Subject: [PATCH v4] backlight: pwm_bl: Fix uninitialized variable Date: Wed, 25 Jul 2018 08:38:30 +0100 Message-Id: <20180725073830.31421-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180716210241.9457-1-daniel.thompson@linaro.org> References: <20180716210241.9457-1-daniel.thompson@linaro.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, linux-fbdev@vger.kernel.org, Bartlomiej Zolnierkiewicz , Marcel Ziswiler , patches@linaro.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Thierry Reding MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, if the DT does not define num-interpolated-steps then num_steps is undefined and the interpolation code will deploy randomly. Fix with a simple initialize to zero. Fixes: 573fe6d1c25c ("backlight: pwm_bl: Linear interpolation between brightness-levels") Reported-by: Marcel Ziswiler Signed-off-by: Daniel Thompson Tested-by: Marcel Ziswiler Reviewed-by: Douglas Anderson Acked-by: Lee Jones --- Notes: v4: - Remove line break from Fixes: and update the *-by:s v3: - Switch to the simplest fix and zero the uninitialized variable. git grep indicates that ~25% of calls to of_property_read_u32() use this pattern (pre-initialize optional properties with sane values and ignore the return code). v2: - Simplify SoB chain (with Marcel's permission) - Separate complex if statement and make other similar calls use same return code checking approach - Tidy up comment formatting and fix pre-existing grammar error drivers/video/backlight/pwm_bl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 9ee4c1b735b2..bdfcc0a71db1 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -250,7 +250,7 @@ static int pwm_backlight_parse_dt(struct device *dev, struct device_node *node = dev->of_node; unsigned int num_levels = 0; unsigned int levels_count; - unsigned int num_steps; + unsigned int num_steps = 0; struct property *prop; unsigned int *table; int length;