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: 142097 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2860307ljj; Mon, 16 Jul 2018 14:03:16 -0700 (PDT) X-Received: by 2002:a1c:9755:: with SMTP id z82-v6mr11192117wmd.104.1531774996613; Mon, 16 Jul 2018 14:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531774996; cv=none; d=google.com; s=arc-20160816; b=qcJMuQNZDxk+lnFNFoYNzX8Txj8Jri5Z1nFqyoXoq8UgaOdwi7zRt5Vq+wurb/AjI9 UmZbqs/ZiV1pGEfG9CelrOvUInak5M30oqbZztNQC4r8PIaHCFHXzrtcYVbFjSnnNo5s SLgav9+4Z2aXPQlq/eU55C7APSS6PKlMVe8yTVN/JNiMRxnLlXqFIz3xpzzWYg6QIFFQ ku6myYQsztMhOjXejMX6YQuL1lJzlXjSY5S0ptD6Q9o0dyZV8jCDgcUvvIjVlJarSYp+ zTd7hKPytEzqgOsAegVJSDJh17qmeS3G+HYRl6W+mLyqlKRjM+b2HTO2tMDplEIWn1Jg EPMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=XtqqCN2m3xu2+xIK5UM2oKwxj9zAXPr6CmFB6iF0ET0=; b=e5sBKUNQaLhIjmQ8gVQPsL5hr6mUuKWDKVnLHBcE8Wng9edXtujCINlgh4TwnjSGrb Lj+kFrDYVReMbFXDf8B9MTQ7AZYGTlKwTFcWTKQqpTnAq1VMKuMcRvwjifwOmhJ8x1UG Xwn0NmpnJxvfbJVPeM1DA8CuUWZQM2UHRoBWmjElgMqLf82rv0PB+f8e2CJzi5k4bfZa vqBE0nhLfYi0Ua/LOhDoEIHHNVXhyAttNIbyR1hmfo7BLitEPYQBe47Uc+DMbJb7IYr1 7q54seCSYNESFX/17u6YSbQQRM1XsZCE7ul6nj5/0dJPTQP6PV55miKlEVD/TMc5emAa A8xw== 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: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id f70-v6sor1019449wmd.52.2018.07.16.14.03.16 for (Google Transport Security); Mon, 16 Jul 2018 14:03:16 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S/sC4JUZ"; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=FKWeFwjUNwhvb5eXsgp7FPn7kt8GtJnWuY4CkG/zaF3Q4jo8FUh5yE8PfPQOSNvHzV mYhkvev2E1TMHHImBI0V1J1PqNHI8SVGp9khUMDosu/qFGNhcXb62F17HnPDX85DFJgo hY4tiurZ4M67pq6rNx9iE2ooFgLjyya7oaTm7kn2tA5HXhwtLw51h6I2hjeViI0iImUK nGqkg2pDeoLQ5VENfSR7NKiONL21IXOC/gKSYiImOCuLoI5rL/4NOIm/37LFmIrgs24d 0wiYaOsvlCncyub8rfiy3iYiBQlOIrYlC4DPGVrQcL23Xaago3K0SKTDaZTbU0bzM3y/ JwMQ== X-Gm-Message-State: AOUpUlGOzkHA58ncA1tvmZX3xIp9vr0nGHcIfYtcRmHydhKLSTkvAE/q drD8qL2vh9FcRBRNghf48aoGayWt 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) Return-Path: 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 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;