Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6654794imm; Tue, 24 Jul 2018 00:13:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpchwjevJiZaHM2bHXBKK4xaUz3u9WsEGOdZ7c9IQl82Dmk2LrliuiQupgZFC7PudZXRmsT1 X-Received: by 2002:a63:455c:: with SMTP id u28-v6mr15251488pgk.210.1532416427304; Tue, 24 Jul 2018 00:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532416427; cv=none; d=google.com; s=arc-20160816; b=iDrfjv7A8+tDSPkN4ErVw3tdxt2BteWG8LmTM+h43FrzY9AGU+pH1/yrGJOzrWk5Zt QJUrESk/qmPdiUU+J6lwHToMMBM/WWeGp25WRs/fsx6gDkCJpmw0ieMttUqouOxge7jM CVcjcjqeauCy6bDZYbzPtrMgWUJRtB6PJGrEDhKKGIBntawl5vUlLvK2M6GfVhtlUefe uhMa/pmGGG/wluyNu/LCWesNQYdwT5KQlBDLZmnBgasvi677ooTC3d5WgIpzStO3uZk4 1a/aLA3GNFo5hswwWhkf/7c/0wYgmsKBSjbs4yjssGycDrHG5y8khl9J/o0rwDm8dsbA 4hug== 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=oLGamEtSDPMo5QXPl/PAJUvNOCABGEBrWaLjnEXWrOY=; b=fmjuUZb2L1nBVa5Gw3KJODM4Vvig07Lf3SrIW4nlfmmmyD8O5ZsXBvr6BewucpebYR +fsnNwRhRrbREdiC4RW5IEuq+4KXgCm3MMOENWE72DhLn017wQKV9t9KblJQMWYuGDHy 5QHB7m0d/Q/VjXYYfnTwGYdVc58n4AN9uWyVS2JQqFiU0UcIMimx1JhAyKhH+b/VBvcQ Odf1xqBZY40bTpI8vL9YnrZXDzi9dZiuKbAUyOhD4gq4snBq2MSLex/ajTur+QC9Q6ov CivMl5zFTkKhxq9fIBylSSCwKMTIvd1BQM98lnk/jsMWHhZko7hC1JU3YdKunNMsiLUF QQFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fETF1unX; 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 n2-v6si10405688pge.74.2018.07.24.00.13.32; Tue, 24 Jul 2018 00:13:47 -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=fETF1unX; 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 S2388400AbeGXIRp (ORCPT + 99 others); Tue, 24 Jul 2018 04:17:45 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44070 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388357AbeGXIRp (ORCPT ); Tue, 24 Jul 2018 04:17:45 -0400 Received: by mail-wr1-f66.google.com with SMTP id r16-v6so2965551wrt.11 for ; Tue, 24 Jul 2018 00:12: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=oLGamEtSDPMo5QXPl/PAJUvNOCABGEBrWaLjnEXWrOY=; b=fETF1unXgJfLeIjJh5EtZTwbWZFBaouvGP3O/7B/reEEmT2L3me6VjtDwkS3QmjnCx dUxa5PmFySpYVstOOvHV+gVH9aOGe52WIm6rmJsCWq//BYgvJeB9A5UOIGDOPC0fk59G LmLYBQ/9/Nd4RhcDUrB23Jlxqcz6hZ9Sly/Q4= 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=oLGamEtSDPMo5QXPl/PAJUvNOCABGEBrWaLjnEXWrOY=; b=UbjLPyyeom301ovKR2+ACJdfogGJm/LQaLxbaTWaHePkspD6PfOWlZtKwW6DdqHY/6 Jzb3t2vOJokc2MhXuBOI17yhQLArh/kzhxsinpjWYaHOmL1nBEpqylyjvLG3bIVHeIl9 B7eZmks572zWWdC4HEuopBHGPwp1nXUvkkLYeBBTCJxwGhcgLeNjY0E04DtNk8/DxKGy TVN0ENvLA9tbwae8vGMxL7dg9ZWIk85Fm/TV36Cz0Bp+hom1TW0BC4wcXFN1XM6l7m53 EUc18IHXt+ZlrKVmA9Qwq52mx6h1yXB5PXd4CMKJeeP+DclUiYdwBIOYEuyqBV+pSu11 O1Aw== X-Gm-Message-State: AOUpUlFLIH9chuqenU5902geoi+YjerQGY0O4aDUPb8F55BJbs/Ea8Km ZyAjb4lVESmnTcuRaWziFyef9w== X-Received: by 2002:adf:e0cc:: with SMTP id e12-v6mr10485334wri.199.1532416362841; Tue, 24 Jul 2018 00:12: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 o4-v6sm736960wmo.20.2018.07.24.00.12.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 00:12: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 v3] backlight: pwm_bl: Fix uninitialized variable Date: Tue, 24 Jul 2018 08:12:23 +0100 Message-Id: <20180724071223.18901-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 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 --- Notes: 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(-) 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