Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2777144imm; Mon, 16 Jul 2018 14:05:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfp7OHhT5MvIVXEgT97aGNhjvHnMsnPfVRo3GmhRdofidAYHYvlael5dBbWGteWfaX5J2XP X-Received: by 2002:a17:902:42a3:: with SMTP id h32-v6mr17891677pld.72.1531775124232; Mon, 16 Jul 2018 14:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531775124; cv=none; d=google.com; s=arc-20160816; b=HBlfvGOePkm0ja+y73BSwhkU/DWQrBA1SoHP0dgaVqNlD2NakHQf3lP8cL1/iSLrWG c0FukEA6fdPlCFVCpZwcSfQ8FNmspihZ75KS0u9usvyC3P+9jM7JyjsNZlnjcpXs/gk7 ocYbN3C3WBbDDlpAzvbbfvDLrHmI2d3A+VRKLKh6fCAQeWVE0DA7NpV3hEgJGcfYOuAD cGzqMJhQUmZHEK9ZAFdo6/l9h4mltv0PSve8qBboiplgp+tQgUJVu/9Ot/wgN5WiWC3v 2Srl1dsVaWQ2bxiEnLFYhVAgqWF82yJyqPd6AMsBW1lJyM9kyZgG/DVhkmkHdqU1IvO5 10CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=XtqqCN2m3xu2+xIK5UM2oKwxj9zAXPr6CmFB6iF0ET0=; b=rvt6AWnxyxzCaW5iZ3r6oN56xbVRnouR1ichVJKULqwY5Yg+s7Efl1YOFdtZv2AC0s JEYxv94N/9xZYAtIeDtTs+T6k5hJxO1XPOLIvSCX37E8gd/yTGMGTFicmg8TuEn7CfSx nJLtLRgqXoC9hyPxeQ2JpwlodFk46L5M0Z4PNQ9KC/uCTsPBC4vyVYGCDV7wiT77JyFt JOM2VFETD5U2f8OYevPzlKWdsT7x8JgbcjIMtDBlA6VroGx5TVh9W3a62AM1MhczgxnE ao8NI5aOQhrM0wlJw2MXBfdUpQhfDr/uQ2IzGAeLBqzpiGPoRdj4WmQndKBFaXMCdIf9 GuOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S/sC4JUZ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2-v6si28641349pgp.681.2018.07.16.14.05.08; Mon, 16 Jul 2018 14:05:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S/sC4JUZ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730232AbeGPVc2 (ORCPT + 99 others); Mon, 16 Jul 2018 17:32:28 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55475 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729601AbeGPVc2 (ORCPT ); Mon, 16 Jul 2018 17:32:28 -0400 Received: by mail-wm0-f68.google.com with SMTP id f21-v6so4275214wmc.5 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=Crxbc7ozjTAnRJ4Ck8JhId+fxw055tRs5hZIF6ZzHS9T0O9TvNJPsX5jIftnANSSeT Rr/xD4Km1EAiLGWJKDch9aEz4AI22Ji3rKDxmU5WqYIjgvNCdQg2Rz0bBOdOwNZRCjfH HkKCbXe66H31pLc5ucwE/TgrWQ5F0Igzdq0X6tcSMQzQvqY9prUOyjTXy5ZVSttWuiAo DkYidQ+DdtysAXzAt1qmwWGQUJFrCk7/GuApDy7pwn5PDkosGRaJAzNZQ6IseUqX0F4l bqzlqXAlrPRS12bYbpLgTzOR3v0tZBxz8FDUqr/X7yQmSV4QpwtKbwJf/hdtoDgqDKvK xYJQ== X-Gm-Message-State: AOUpUlGO1qF7KKzZapwmtE/K9JRYH1AtmQyfA/ZYdkdPXK0ju744ncnM 8V+2grm8VkW3aq8YrlWq8RCOjw== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) 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; -- 2.17.1