Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1173411imm; Sun, 15 Jul 2018 00:58:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpefY/VLcIeQDZyvQoSIIAThEQZYPg59Kq0k56yOp4fU03nNl1FXhAwLTa9MfMZUe/r2XICb X-Received: by 2002:a63:26c3:: with SMTP id m186-v6mr11663228pgm.56.1531641507197; Sun, 15 Jul 2018 00:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531641507; cv=none; d=google.com; s=arc-20160816; b=EOwfs7856yWWcIsEd41pnDJCOOvZLIQYPi/o2acBSCzrHUFQcxAJzn76z1fLmEQ+S9 X5bJrxYdSlhzIDb4g63U/6ZXG5gEbW8QHO8eq4KJ+c90/XCYdNuVXJcURjMhNsSV4z47 aBWGXMgwTlCVvOf4K0WnwXJOXagXVAYqyDClaChiMi6s65nQzawWGlJADZwV0lJsnpb0 vGXBAC2s9LipFrcoB7czoveFmQxc/ZC1nfJPFOZ0E0q7pBqBYHHAp7L+FStZFu7N+jyU kH2j06fPQ3r4khq9k65N3VwPmCCnazMcXozLwXyajNzpFZ1zNCKwrjB5oS1sJEM10umI YfxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=qn7AHJe0dTeyuO8lEgP6SC8Eme/jAWPcuA7m8Wzd+88=; b=dLh9Cj7reEQMw4I74I2OtsUZ4xH95ca5UxV3uprHm7OwbtDxAZnbRLZRICaylPtQZG S1FsFjPcr21krbta06fy7+vyB1+0/COyWyHikAcMGF+CQ8n9716z/xtpJzPYeNWT8V7+ fNjM3P71+dIOXzHoBqc4+733PdhX5cKsm3zlD9Dyx7kBkAvBLsJZzbgzljBT4hnroxHZ 9ulqJsS82H0OtpYLb1UaGKGIJJC2YvhuZnnpboZKxpBqZWqd1nzRTcTABJ3toZDWz8fN i2fg0BenXeYxTqBUJViIEqEoMLYRFvvmZsWhUZchgY7WwMPHa5s6XllwlWc8hBqtRB3G JKGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GKLebnQT; 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 c8-v6si26158796pgn.473.2018.07.15.00.58.12; Sun, 15 Jul 2018 00:58:27 -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=GKLebnQT; 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 S1726277AbeGOITm (ORCPT + 99 others); Sun, 15 Jul 2018 04:19:42 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:39995 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbeGOITl (ORCPT ); Sun, 15 Jul 2018 04:19:41 -0400 Received: by mail-wm0-f68.google.com with SMTP id z13-v6so12867619wma.5 for ; Sun, 15 Jul 2018 00:57:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qn7AHJe0dTeyuO8lEgP6SC8Eme/jAWPcuA7m8Wzd+88=; b=GKLebnQTF7Sinz9XGaW1IW3y3+jOphW6T6Mo/y+kpN1C0nJPA+yRKgT5BR0lH78g4g bownZ6n7Cxw56vHTYl6gSvchVMCvkJtzxCDCEc3Q7aVMvncdnidImR97yyjIzkugjnFA JFfw5GRiG6ympVtYan90AV6CRdoeIY2habCcA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=qn7AHJe0dTeyuO8lEgP6SC8Eme/jAWPcuA7m8Wzd+88=; b=aGFswcqGvAaH7yIxIOrEpJEswlfGT4C5Gs6M61CVm35dzvyafqAdDn5ROHunbHoslW rRFZWW4MNf9BmfMVGUI1oylXjmex4v9wzMOfzz6L4a1y+5vN5F/hZl9EfqMUMBM1KBOI fMmpyZSBzeMkrGO9d/OEYfHOaLD53AhuRA/f536uTbZfYzhEfhIo3/g4aTRJ5PQIrm2Q dYM4Q5SYxxNeIsmzRXgD/EGQK+Uj7KSTsHAUwN3DKT6XKlwLCzheaG7EpSUk2p+u2XMa xeMpFUCUe1WlEkV17zYDn/XuGgoVIL8rjYS+cwvyWFYWvQM5bfy+K/iJsA50llUlH0y8 C0QA== X-Gm-Message-State: AOUpUlHVljEE06IfjbQ6NbnGk+tCyL08ZSVgtmB/NztGpsqLfy/AA7uy V3KGtWGUwpkkFLB/mWMre03EDw== X-Received: by 2002:a1c:8682:: with SMTP id i124-v6mr7704336wmd.77.1531641456287; Sun, 15 Jul 2018 00:57:36 -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 n8-v6sm42829169wrt.56.2018.07.15.00.57.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 15 Jul 2018 00:57:34 -0700 (PDT) Date: Sun, 15 Jul 2018 08:57:32 +0100 From: Daniel Thompson To: Marcel Ziswiler Cc: "dianders@google.com" , "pavel@ucw.cz" , "lee.jones@linaro.org" , "robh+dt@kernel.org" , "enric.balletbo@collabora.com" , "rpurdie@rpsys.net" , "linux-kernel@vger.kernel.org" , "jingoohan1@gmail.com" , "linux-leds@vger.kernel.org" , "jacek.anaszewski@gmail.com" , "devicetree@vger.kernel.org" , "kernel@collabora.com" , "briannorris@google.com" , "amstan@google.com" , "groeck@google.com" Subject: Re: REGRESSION: [RESEND PATCH v3 1/4] backlight: pwm_bl: linear interpolation between brightness-levels Message-ID: <20180715075732.GA2989@wychelm.lan> References: <20180409083333.1249-1-enric.balletbo@collabora.com> <20180409083333.1249-2-enric.balletbo@collabora.com> <1531580895.7579.7.camel@toradex.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1531580895.7579.7.camel@toradex.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 14, 2018 at 03:08:17PM +0000, Marcel Ziswiler wrote: > On Mon, 2018-04-09 at 10:33 +0200, Enric Balletbo i Serra wrote: > > diff --git a/drivers/video/backlight/pwm_bl.c > > b/drivers/video/backlight/pwm_bl.c > > index 8e3f1245f5c5..f0a108ab570a 100644 > > --- a/drivers/video/backlight/pwm_bl.c > > +++ b/drivers/video/backlight/pwm_bl.c > > @@ -147,7 +147,11 @@ static int pwm_backlight_parse_dt(struct device > > *dev, > > struct platform_pwm_backlight_data > > *data) > > { > > struct device_node *node = dev->of_node; > > + unsigned int num_levels = 0; > > + unsigned int levels_count; > > + unsigned int num_steps; num_steps is not initialized... > > struct property *prop; > > + unsigned int *table; > > int length; > > u32 value; > > int ret; > > @@ -167,6 +171,7 @@ static int pwm_backlight_parse_dt(struct device > > *dev, > > /* read brightness levels from DT property */ > > if (data->max_brightness > 0) { > > size_t size = sizeof(*data->levels) * data- > > >max_brightness; > > + unsigned int i, j, n = 0; > > > > data->levels = devm_kzalloc(dev, size, GFP_KERNEL); > > if (!data->levels) > > @@ -184,6 +189,84 @@ static int pwm_backlight_parse_dt(struct device > > *dev, > > return ret; > > > > data->dft_brightness = value; > > + > > + /* > > + * This property is optional, if is set enables > > linear > > + * 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); ... this is not guaranteed to initialized 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) { ... and we make a decision on it here. Marcel: Can you try the following quick fix? It's untested on my side but very simple... From 6fa2fbeb017086147ac61981107a95cb8ae7b4e7 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Sun, 15 Jul 2018 08:49:05 +0100 Subject: [PATCH] backlight: pwm_bl: Fix uninitialized variable Currently, if the DT does not define num-interpolated-steps then num_steps is undefined meaning 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 --- drivers/video/backlight/pwm_bl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.17.1