From patchwork Tue Jul 24 07:12:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 142710 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp6931168ljj; Tue, 24 Jul 2018 00:12:43 -0700 (PDT) X-Received: by 2002:a1c:e70b:: with SMTP id e11-v6mr1107625wmh.22.1532416363051; Tue, 24 Jul 2018 00:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532416363; cv=none; d=google.com; s=arc-20160816; b=ACuS4fslLCQ6A2hxVm8TfEkYdCHc4JQCMoDfRQ26QS9lEng8igQCVFy7owiRlskmZo Ek2NtveaPEO2bF7mq0/0WKenTjzJGvBmYpbxd8dB3KoEoIjtykPuztw6hWNP+7i9BcTn jS31+7Ie64i2zkxSBt9xX5nyGko3zJaySZPRxyxvqZtl/NWEokuKxOOlL8OUw0DFL7KX sZCtgWbwwT2VrOiexGLI+lSwAeVgcpRXExf4RalEi3ddU3fw4Yuu17QPADjwKGr9JMlg gRDacP7+An4bjZOqoj5qCJ5E6dkb5OW2mNgT99wFI+ViFS36CnbVbmK8ZV1tj1tlVMfi 8HAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=oLGamEtSDPMo5QXPl/PAJUvNOCABGEBrWaLjnEXWrOY=; b=JVE27Z6NrhhyfZoXpGtlP4dppYG0CCg24fVaQMVcr0CvNlyKbOs+9Z4fmwCEY5W1G+ 0lcTTMiy/Ra7Y62m2C7SQ3dIo0doJyhI94yWJUIH8d/rH/M3/4WOY+NaD1EIVXhPfpk7 C6OH/oUU/S3dD7Ng1mrGMrMFyELbZ0yO0tykuhVLUcE7j4RRU/nH0GVu8qG431tSBN4u QYRwLebJ4Ygwkfghm//u86j+UbAg6odfqnxBsd7yZ1EYF30BdckoRaGG8bqrDWnMarwE TqdWhld7Jp5dqYkipfiNQib4LFH8kjICyjUOQRr9HkppEfyfy/uPpfJoJSmvFPAgPZWB xNVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fETF1unX; 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 e15-v6sor4067643wrn.18.2018.07.24.00.12.42 for (Google Transport Security); Tue, 24 Jul 2018 00:12:43 -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=fETF1unX; 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: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=uoV+L64Klsj7Gej5Kke14etofd+TBog5e3LGKPNoq68JdkwXWRUu+ZMPdwFBqHz4Tq 8xlgpl2kxPtd27bmeK8RLhA9rfa/hjA/0M+AfUFTbMIbagHc90sR9abRJiMdqqtrRQgq JamuKs/y+rGreUTh/DiSX/bwEeMXH2tmhBgs2BlmvBRPSO+M267FPqE2B25kX7EKEoSs qWI0fxdcVRnbegxC5rUPyxKCjyO50/T4Qy1HXADbSYKqL77i4ruLmZqD3aLKggxLrdkJ /k8/yvRbDHcuA6OlndX9WpBwhzIRc5awYXQOTA6b8bkgqVPSLEnPWZvF4tGS67H8QDtc hq3g== X-Gm-Message-State: AOUpUlFlSZZToTjnqbEIJMtjbapOarepm1Mrewqs0ERQs4haU0MODqOZ ok3uCB7J6LBaHzAQvGgToxU0jjhU X-Google-Smtp-Source: AAOMgpcwcvQd2azYXOJqMoTQDJ53zjerDbsXx5oTceRpxQ57GvQpgUcvuzwvsMUPoCjgQ1tU1IuLng== X-Received: by 2002:adf:e0cc:: with SMTP id e12-v6mr10485334wri.199.1532416362841; Tue, 24 Jul 2018 00:12:42 -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 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> 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(-) -- 2.17.1 Reviewed-by: Douglas Anderson 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;