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: 10527699 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 E5AD96037E for ; Mon, 16 Jul 2018 21:03:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D953E2835B for ; Mon, 16 Jul 2018 21:03:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD1EC28C35; Mon, 16 Jul 2018 21:03:22 +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 7DEF32835B for ; Mon, 16 Jul 2018 21:03:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E2016E44D; Mon, 16 Jul 2018 21:03:20 +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 A546C6E44D for ; Mon, 16 Jul 2018 21:03:17 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id v25-v6so16463034wmc.0 for ; Mon, 16 Jul 2018 14:03:17 -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; bh=XtqqCN2m3xu2+xIK5UM2oKwxj9zAXPr6CmFB6iF0ET0=; b=IW8MSzoLYgz15SloFG8bZ9PQaD8Mx1VTHsT+A/TJ9dTz3JofK5QHAbq9XZ6Nex4tTM MIkE4btUjTIbPnLZrzE9UKtyhWwke7OtHJ/FjFrknU2lt/Luhw8BisakIkd1jquI2oH+ vIJjKafxRn8OWo5rhxh54bTXE2osI8fX/IXaWnrjHD1PfotUUFZwNe/FJpqwPiBl3Oqy 2L3IdKvyKp1U1KoaNk46yiHlA/LEH8rG7SSlU1UaplADOfsCAR477Wkopyg9qaZQY8KO kUtUlXE4Xd/pKzl1iKvwHPfYejPhq0iA+rLQFschB9QCMbpQw63+jvy8RgHhSmzPPTxN Ur5w== X-Gm-Message-State: AOUpUlHe8JdNRhy6oAXDOKBzbHgzpvUL4Fc2TkQ89vBHRJLkSmcbq8p9 ntuCQwip5va0fwSvbRWn98GFgg== 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 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 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 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 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;