From patchwork Mon Jul 16 21:02:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 10527695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2EE0060348 for ; Mon, 16 Jul 2018 21:03:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21E742835B for ; Mon, 16 Jul 2018 21:03:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11BAA28C35; Mon, 16 Jul 2018 21:03:19 +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 A64922835B for ; Mon, 16 Jul 2018 21:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728412AbeGPVc2 (ORCPT ); Mon, 16 Jul 2018 17:32:28 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53798 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728734AbeGPVc1 (ORCPT ); Mon, 16 Jul 2018 17:32:27 -0400 Received: by mail-wm0-f66.google.com with SMTP id s9-v6so9102995wmh.3 for ; Mon, 16 Jul 2018 14:03:16 -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; bh=XtqqCN2m3xu2+xIK5UM2oKwxj9zAXPr6CmFB6iF0ET0=; b=S/sC4JUZWZNQryEq7Tf2YQbA7CF0BR7N6sSfHLD2XJomM9ML4dbQG7N6CpF19WEnLZ JymdPNbBfOmRQydOR5udU5U0KHVDYMAMEXN4a+9xpjJAo179Km05l1IENAGz0RlHDyey VVvw/KQ/dvFW6FvQ65H5a6cOXhkPhEgG7wYgA= 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; bh=XtqqCN2m3xu2+xIK5UM2oKwxj9zAXPr6CmFB6iF0ET0=; b=BuXOoOIIjQjThKE8LkM0CDNUibUd93lo8YJ56fmU56ZBSsZSL3a94R+dB5cUQtJefE Tzp5fRqhxNRm2q4smEl1THhRPwXs4Y8gWtP8IM/ZfZwr9pbD15EEZo/lSx55yamyD02v dQ2rlUUhHylYy+knQ09/rCg+jHAGgPvUl77dcliO8xFw8t5o/8l0G0xY9/95HBDApsse 0rfYEFWEvr4N+4U6pwz2ih+dg+SzuPBMQ3b9kmqCbxOAiADCVo1la8RtIS5LgpVlgh4t qgc4h3Fbt2dWRQm+pLRCkx3eZSV7BGZ00qSYdX2QGo3g34JWQL/YeW6F1qGUQMqo52mX 42Gw== X-Gm-Message-State: AOUpUlE+sh3yDz9gFdSueXLjZcHdVnggENvpaN+tOJlu6/mMMX805Eui 87eY/orbEqdyEAs7fX1VC88bEg== X-Google-Smtp-Source: AAOMgpe1r72w0fHi5KLe2PHYwWQebahpDRj3TY9tbmn0Uuk/vQspoBFxh851a5ni3+31LBODUu7/yw== X-Received: by 2002:a1c:d892:: with SMTP id p140-v6mr2649336wmg.76.1531774996308; Mon, 16 Jul 2018 14:03:16 -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 u135-v6sm15127923wmf.2.2018.07.16.14.03.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 14:03:15 -0700 (PDT) From: Daniel Thompson To: Lee Jones , Daniel Thompson , Jingoo Han Cc: Thierry Reding , Bartlomiej Zolnierkiewicz , linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, patches@linaro.org, Marcel Ziswiler Subject: [PATCH] backlight: pwm_bl: Fix uninitialized variable Date: Mon, 16 Jul 2018 22:02:41 +0100 Message-Id: <20180716210241.9457-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.17.1 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 this. Fixes: 573fe6d1c25c ("backlight: pwm_bl: Linear interpolation between brightness-levels") Reported-by: Marcel Ziswiler Signed-off-by: Daniel Thompson Signed-off-by: Marcel Ziswiler Tested-by: Marcel Ziswiler --- drivers/video/backlight/pwm_bl.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) -- 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..e3c22b79fbcd 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -299,15 +299,14 @@ static int pwm_backlight_parse_dt(struct device *dev, * interpolation between each of the values of brightness levels * and creates a new pre-computed table. */ - of_property_read_u32(node, "num-interpolated-steps", - &num_steps); - - /* - * Make sure that there is at least two entries in the - * brightness-levels table, otherwise we can't interpolate - * between two points. - */ - if (num_steps) { + if ((of_property_read_u32(node, "num-interpolated-steps", + &num_steps) == 0) && num_steps) { + /* + * Make sure that there is at least two entries in the + * brightness-levels table, otherwise we can't + * interpolate + * between two points. + */ if (data->max_brightness < 2) { dev_err(dev, "can't interpolate\n"); return -EINVAL;