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: 142848 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp495045ljj; Wed, 25 Jul 2018 00:38:38 -0700 (PDT) X-Received: by 2002:a5d:44c6:: with SMTP id z6-v6mr13406594wrr.236.1532504318599; Wed, 25 Jul 2018 00:38:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532504318; cv=none; d=google.com; s=arc-20160816; b=0Nnuf/6EZo8tS9sb3zWPIVm4ZW/PWxoA//msg7rD2mi4GeKNLcaUFl62//jV/LEBmr aLpwh4U+GUObhtjUsoFUVcMFH51F/Dr/0WdyyV2BSRHKeqqBJ2GoVpnGOq8SYcKPwyJV CE5ssoRWyfXXne/rTdJgBy5PjgQaIZ35w1rtH1RCrxiAmUekyimhG0T6Bxn6/CbFjkmY pWVVToto2tVc1+29xnND7cAVkIwoULeew6sP8KUDv1ulFIOsQ3PHSRTpqIb0dJxBSAqw G9K3dBp9FBGtEYgaeQpAIFTVDeaLGOw06iLBLtjszcBUbFfB7hh4ccCNItrKQw5sAc5/ ou5g== 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=cSt1pwQsxGzBw3uquJPq4af2a8gX01/8NUMRtpKzH84=; b=p/3gDylvmmVRVUWXvGGddjVi4i/d2WEuc6H83f9OMRA1WxyRuMztrUKhOJB/riGVoD fSFuY0Zonti/wu8BrIpG+m5xyUAfYwv887iPwkx5vykJqrP8SLm+498U/qTjHcVNaYeB xThhJS2fADVnE+dK8dglQnlxIKdHLJctM65f86xiFQ+j/4jt4tipd2bEcnwgdcJy6I/z PqEiVWEujOuml+utwpldda5sx7OEbOtlV9WT40yC1oKQtTep6i0WDI1Yan0b6+E8D1xW Gf/gMMLinTwJcjPdibNZP9PMVi/QQBPjaNakhxzOpo79t7zZJIRBf5n9ZVm5vEdaxOS7 W+mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XQxr2vkb; 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 125-v6sor956135wmk.50.2018.07.25.00.38.38 for (Google Transport Security); Wed, 25 Jul 2018 00:38:38 -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=XQxr2vkb; 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=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=EKvpaLiA6jN24Kwm5X9zKRqJmnKy+lCIIrNL2iYi2zi/CgGC2xLjPtPnK+yF5NKZKj s4HutcAeGcaIuaAJ0kscJ52AGf3wfS96eXVdn01pWXZXdLVzv4IGxCAf0lI3RNXZoQ7G eGkNLxXVaPA3E+UzooMDHbvXPrAdV3/IEa4dmBrmbx6XclLx6ILGsJj9S3gb8IG61f74 nnTrBp6TwgRD8W//VVrKc2Pc1Leq6rQyzATTzLC2yYqfNFLwAjw247+AkUHlRfdwX6UQ BbQnSwRpWceIgU6ahE3NdRBwQ1g8l01EBn8fI9yqB1tS0a+8hkQT6ZiXMPsp6YYm7Q8c TDVw== X-Gm-Message-State: AOUpUlHu+9LK9eAnFoEtSFzjMCGL02kfz8L13lWt/aAyYLRCA8pTrJwR asUUYl+byl/Zg1fV5ZyU4Wt5hAvh/vBpoQ== 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) 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 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> 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 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;