Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1883514imm; Thu, 19 Jul 2018 09:20:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpep8tMpXGALodLixlZQfdWQw+5Te3f+YkxeaGvuuF2P3nx26t5uFac0XKuWTfS5fGu2hs78 X-Received: by 2002:a62:3c4f:: with SMTP id j76-v6mr10280471pfa.119.1532017236075; Thu, 19 Jul 2018 09:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532017236; cv=none; d=google.com; s=arc-20160816; b=Hd8YMOt3udzvF9dna7gNnRs3glGs6sCZv33Dc6LVJN7pkBRfGTQn+vdp0x2wEVJ3we 8uozT+8sJnvA+yVWGOyvQkKNw9mdKseWIaTadOjVn8ubjWDKgS2pRLDZ1qOwKJnq35f/ g1pdoecfZcH86Nk7I7o5bb99wJkxfrYB4dA3/hty6Zg3bn6syJOWe0MM7kHSxywlDFNz cWx+LrwNFjw3fZVDMEEceK/cdUNHYopQHxY0BeBMAvP7uV+saKEdIRHyd9sQ0DRfP8Ah +WXakzuC/J0OaFa4iQVXtcvFDUKfIpC2neti/hPPQ4o8fUadb35AXsFolKwUq/oBud5s kNWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=mtoEkUenwKXEVaYbLXYNYms73QdfgGVwiTkvGMMXbUc=; b=G8r6e0ccHlSXZSNPZGvVifrRpIR3MwjHW4u7YMKqyEzJC+vjwbB8VjPah/rUjUiR7f F2ggf7FnfHSaLoMxGI1hHZl5LN4QQSgPiHW9ov8g6X0enW6K40wEPejQBCErqssGCNqx TND9hboJ9aO4ElrGEAauK4wHwmUqeoC1QZKLy53e8oO+VyRZkSEots4aEQP9Wj+QQ61j EZ0vjX7oT3vXJZtTFDdydarJSAEj8BlAz8qMfEdBYJGQjqDIfad8hhHljmXZbqD9astl V6kup2uS+FW3Y9owMg28q46cQXgEYsyVdmoIxqUudYMvkC+eo4zCBIQrR2r1ZJSVIPT2 Zzdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h7HCB+Ti; 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 y14-v6si6368312pgg.76.2018.07.19.09.20.21; Thu, 19 Jul 2018 09:20:36 -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=h7HCB+Ti; 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 S1732005AbeGSRDh (ORCPT + 99 others); Thu, 19 Jul 2018 13:03:37 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38996 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731699AbeGSRDh (ORCPT ); Thu, 19 Jul 2018 13:03:37 -0400 Received: by mail-wm0-f66.google.com with SMTP id h20-v6so6966250wmb.4 for ; Thu, 19 Jul 2018 09:19:43 -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:in-reply-to:references; bh=mtoEkUenwKXEVaYbLXYNYms73QdfgGVwiTkvGMMXbUc=; b=h7HCB+TimIpmhToaMwJaEFFBzqR+qNrE9o1oaW0duPE1abrV7PPQPZ6duGld4DAnke FSDCW+uiu/Gg0rxhhYxKBN0L1bCrk4qvROu6rRJwh82SE6tAoAj/dL/aeHfkaebJoK4U xpMckLeth5OMVrl60O0VGUoTh2YpM4CX+I8og= 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:in-reply-to :references; bh=mtoEkUenwKXEVaYbLXYNYms73QdfgGVwiTkvGMMXbUc=; b=LymxUd4EGx6TRE4HmDLBuFQjnLIzl6R1nFCF2VG9ccTw3ym4QmKnqOOF93ivzemWhH 7SirNPbFi6i7poVb66WYMS15ZE6sceMunIJGSJwxtx54tQDW5CWv3m1IA1w+lvp+TLql GV1/yd05902RPI9R4Thgg53FIH09wg97nsi7NR737gCNQ6bEG5RoYWBu7yLnvIN0yLuU +LNohERFoqqeNfO5VaLQ1jILxhzr/iQ6PihseVhd2EG4xbd+hKPl2ow6RDAUDXP5l4Wk Ef02eF6Sk8ksrMqudiAeHcSqBf4CWX+73Zqfqa5CJLyCHtmkGZgLRI8y5+V7lQKqVZwq J1Yw== X-Gm-Message-State: AOUpUlFI/pFtd7Tiyu+i4nk9SULPRGDruvF0CPh6Wk14ryBdsshTwwqd DC3+UXAoADdkdWEU6B6/dVOONw== X-Received: by 2002:a1c:90e:: with SMTP id 14-v6mr4753800wmj.130.1532017182509; Thu, 19 Jul 2018 09:19:42 -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 r125-v6sm9610361wmb.27.2018.07.19.09.19.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Jul 2018 09:19:41 -0700 (PDT) From: Daniel Thompson To: Lee Jones , Daniel Thompson , Jingoo Han Cc: Thierry Reding , Bartlomiej Zolnierkiewicz , Marcel Ziswiler , linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v2] backlight: pwm_bl: Fix uninitialized variable Date: Thu, 19 Jul 2018 17:19:23 +0100 Message-Id: <20180719161923.21510-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180716210241.9457-1-daniel.thompson@linaro.org> References: <20180716210241.9457-1-daniel.thompson@linaro.org> 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. Additionally fix a small grammar error that was identified and tighten up return code checking of DT properties, both of which came up during review of this patch. Fixes: 573fe6d1c25c ("backlight: pwm_bl: Linear interpolation between brightness-levels") Reported-by: Marcel Ziswiler Signed-off-by: Daniel Thompson Tested-by: Marcel Ziswiler --- Notes: v2: - Simplify SoB chain (with Marcel's permission) - Separate complex if statement and make other similar calls use same return code checking approach - Tidy up comment formatting and fix pre-existing grammar error drivers/video/backlight/pwm_bl.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 9ee4c1b735b2..f7799f62fea0 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -284,30 +284,29 @@ static int pwm_backlight_parse_dt(struct device *dev, ret = of_property_read_u32_array(node, "brightness-levels", data->levels, data->max_brightness); - if (ret < 0) + if (!ret) return ret; ret = of_property_read_u32(node, "default-brightness-level", &value); - if (ret < 0) + if (!ret) 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. + * 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) { + ret = of_property_read_u32(node, "num-interpolated-steps", + &num_steps); + if (!ret || num_steps) { + /* + * Make sure that there are 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