From patchwork Tue Jul 24 07:12:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 10541371 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 A946E1805 for ; Tue, 24 Jul 2018 07:12:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 938D41FE8A for ; Tue, 24 Jul 2018 07:12:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85E38285CE; Tue, 24 Jul 2018 07:12:45 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B43C1FE8A for ; Tue, 24 Jul 2018 07:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388369AbeGXIRp (ORCPT ); Tue, 24 Jul 2018 04:17:45 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45779 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388331AbeGXIRp (ORCPT ); Tue, 24 Jul 2018 04:17:45 -0400 Received: by mail-wr1-f65.google.com with SMTP id t13-v6so2967784wrv.12 for ; Tue, 24 Jul 2018 00:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oLGamEtSDPMo5QXPl/PAJUvNOCABGEBrWaLjnEXWrOY=; b=fETF1unXgJfLeIjJh5EtZTwbWZFBaouvGP3O/7B/reEEmT2L3me6VjtDwkS3QmjnCx dUxa5PmFySpYVstOOvHV+gVH9aOGe52WIm6rmJsCWq//BYgvJeB9A5UOIGDOPC0fk59G LmLYBQ/9/Nd4RhcDUrB23Jlxqcz6hZ9Sly/Q4= 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=oLGamEtSDPMo5QXPl/PAJUvNOCABGEBrWaLjnEXWrOY=; b=NQvKvHIM9cDAhLS4wWYLW6YvY/T7FKuXGK4x3m6+hwfSU2DuMO3qvgt7AB/X3FzfiZ VduHOzHAvHIiWHM09dzk93OcR+8x8k0HTDSjhfZS6RX3K96xCqVRLBV1C25mQL5rqrx+ 02nqMIJ7a9NwehJyPXo+5ex1pSrP+UWhrZGkuADaN/TmtkocTtjpa6vKCQbiU0V21gio rcCOVPvW5mrbiZ64XKtumPwjMo3j/ZdQHTsYBwDzD5LoFL/wb2dba5Hsr4aUqgdFJxSo vmT6DvgIj2uRPvv68ijXAQvBWVwRDO8cQq7OS8CPMUDG0Vhb8alnbFnrvGft7YurUpBd Wfug== X-Gm-Message-State: AOUpUlHrpTFT01jBbgfLDOZayUguTq4RJEaVGUgG5XpCsbnebnTA3zvV uG3/Sb/1skUCZRq/YwH2MyijZQ== X-Google-Smtp-Source: AAOMgpcwcvQd2azYXOJqMoTQDJ53zjerDbsXx5oTceRpxQ57GvQpgUcvuzwvsMUPoCjgQ1tU1IuLng== X-Received: by 2002:adf:e0cc:: with SMTP id e12-v6mr10485334wri.199.1532416362841; Tue, 24 Jul 2018 00:12:42 -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 o4-v6sm736960wmo.20.2018.07.24.00.12.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 00:12:41 -0700 (PDT) From: Daniel Thompson To: Lee Jones , Daniel Thompson , Jingoo Han Cc: Thierry Reding , Bartlomiej Zolnierkiewicz , Marcel Ziswiler , linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v3] backlight: pwm_bl: Fix uninitialized variable Date: Tue, 24 Jul 2018 08:12:23 +0100 Message-Id: <20180724071223.18901-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> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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 --- Notes: 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 -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;