From patchwork Wed Jul 25 07:38:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 949066 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pwm-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XQxr2vkb"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41b6Xw4nvxz9ryn for ; Wed, 25 Jul 2018 17:38:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728454AbeGYItF (ORCPT ); Wed, 25 Jul 2018 04:49:05 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:39533 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728441AbeGYItE (ORCPT ); Wed, 25 Jul 2018 04:49:04 -0400 Received: by mail-wm0-f68.google.com with SMTP id h20-v6so4900044wmb.4 for ; Wed, 25 Jul 2018 00:38:38 -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=cSt1pwQsxGzBw3uquJPq4af2a8gX01/8NUMRtpKzH84=; b=XQxr2vkbGxb5Npumn7LinVcpj0de4epDl3HQyGlzcyj+oyE07jW3UHqUXqtTbdwK1T cVrBuhgCAPb8ThnG4OGRSMkzBz7qTCbwmjk07dvdCRDl1r+daD8Kaxz/gABqrW5bQJXu 7dAQCRXeFlNY9qhpngSrJAnEo+CFOItyzMbiY= 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=cSt1pwQsxGzBw3uquJPq4af2a8gX01/8NUMRtpKzH84=; b=LV8K5OoihDlQJowWSeXWGLcKPuaIHeoXGBUWb3Oi5LI35MZ8I3MxmYMOqv9uiDWm1/ VmtJWcw6fZlaRBK9wSgOilsvqxKs0TKCi4O8rB2MiNiz3psniEy/tGEjB6fMHHap/F+o h9ZgjJf3HJWmCITg5kMjezTYraSI8U6lFsq8N8arCyM87Viw7Z/w/3OvLW3o5QvY0rRQ hzLK8VD6m/NcW/zVyymaWVwnaJKPWO1u5+MxIsGV/f8E4IASoSQvwKa0X5mmcVmgTcxp LX9OsyDDQVgCaL4/X7pxCO9wbJp5PhqJZdRLMrUQxUOTRqZsKO1guejIdqb3e74rG9Sl SMxQ== X-Gm-Message-State: AOUpUlEDTkyk5u8uuN3bzftQtICR1wmspUGLBTVoXHqiBKCteZLoYXP3 SBnV022FBb00gNSt2yD1LCNGPA== X-Google-Smtp-Source: AAOMgpdJmDFN1yo6ugml6NGoyoPnSjZ0Zge8XeT8R33erBCUa3bzorJIIIJfXN5a2aFc5ttwCbGhTw== X-Received: by 2002:a1c:8406:: with SMTP id g6-v6mr3666024wmd.18.1532504318356; Wed, 25 Jul 2018 00:38:38 -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 h7-v6sm10243795wrs.8.2018.07.25.00.38.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jul 2018 00:38:37 -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 v4] backlight: pwm_bl: Fix uninitialized variable Date: Wed, 25 Jul 2018 08:38:30 +0100 Message-Id: <20180725073830.31421-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-pwm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pwm@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 with a simple initialize to zero. Fixes: 573fe6d1c25c ("backlight: pwm_bl: Linear interpolation between brightness-levels") Reported-by: Marcel Ziswiler Signed-off-by: Daniel Thompson Tested-by: Marcel Ziswiler Reviewed-by: Douglas Anderson Acked-by: Lee Jones --- Notes: v4: - Remove line break from Fixes: and update the *-by:s v3: - Switch to the simplest fix and zero the uninitialized variable. git grep indicates that ~25% of calls to of_property_read_u32() use this pattern (pre-initialize optional properties with sane values and ignore the return code). 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pwm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;