Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1009952rdg; Fri, 11 Aug 2023 07:08:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2tM3gFPV98wlMnG+2Jhlz9SlP6PCUdnm9SXepb3uGxfA2sva0QtSjdX1qoC2kcZQyIsf+ X-Received: by 2002:a17:903:230b:b0:1b8:e2a:9ede with SMTP id d11-20020a170903230b00b001b80e2a9edemr2035397plh.25.1691762937441; Fri, 11 Aug 2023 07:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691762937; cv=none; d=google.com; s=arc-20160816; b=jh6A2ruTGLD0IF71QOVQsbii8jCllRMiJWt8GrAl39CISZY1JFSloX9CYdafZXtmF8 giQnVzdA0uFmhstk6z4tIxr9AQAePci4q7cqyJmssqQgk/0xR5XbqRDB1nBv/wii8mrg DU0vaZc9mgX+Cdo7s4OXLxFrVLuBuQ/DG6p9q2IizfBj6aAlcnykXjAatBg+RSEqCVlz IjUlyNklLjOkoG3Tz84GfkXvnc7mb6VvLh2MWXAnwPsdnj0jwH9r9Chf5fzOv8/qFdLD G+wKj5cljRWX9+PdMYYIqntYUMfqAWs4wH1TpWYqFXphh2bXCJxSuBf3g10Zk0whaa82 f00w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=4lOM2JoDw6GcSyfRdNmSzLUKUEXOeJvyPPYfgL5kX3Q=; fh=ZxEGsGrf+tvhXf7W++bv30TNHWcV9rvGV/V26Qh3v8I=; b=RhEraY8FdHTz1ejQKTCYiPpW0Y5cSNUgt/O2S5xD4GxVCwGUjTooRtzrfyrg+XYZJd neib2uZVuy5Xl5YhkHY6aoWdxpW5s/jKO/Kk5a1IhQDOzd9lfqGmmmbZ/5UfvZe47m9k ORqcXCxqHyj0KvrO4UfykURNLNpiGclNMeMyY97eiz2EeNLbpy/zu9jRsQMTpPJ7a16+ V4uiPUvBqftq3889kKZla0Th+fNHDm/DPjiT/uVW4BKVMsZz5dAPsT9zN/qJVs22ksQY 5Q9UNh9+uN7nG82f/JvA/dZFqL4etelHbP87m1/5L+AN0mEr8sjpljtp8pI1BHs3VX1B Nfew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kk9odl1Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s20-20020a170903215400b001b9c992945fsi3283540ple.555.2023.08.11.07.08.44; Fri, 11 Aug 2023 07:08:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kk9odl1Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234833AbjHKNQK (ORCPT + 99 others); Fri, 11 Aug 2023 09:16:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234382AbjHKNQI (ORCPT ); Fri, 11 Aug 2023 09:16:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 383AC26B6; Fri, 11 Aug 2023 06:16:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CC1436576A; Fri, 11 Aug 2023 13:16:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D0F1C433C8; Fri, 11 Aug 2023 13:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691759767; bh=nukkFSLL4P8Jr+p/dmzT3QsEQ0EGjj5/yMaNaTXyids=; h=From:To:Cc:Subject:Date:From; b=Kk9odl1YytqoGOgtcDfjLlBMzw5GoL/OKM8j6hffFD3mw5FMyFVc3K9ILEbj2+081 pudtq1NP5/tZa9Wexobiem93LieQudBbg0eQ0ZtMTvKFqc/JUIXG6/7qQjCcf4XzNO 5HfPJF5svI+wL9XINgVDjKLj+ckSslUBaPJoyy+uVJLR8O3KII72czlYyb76JV7EOm AFgBt9FpIcTgeCBFdobX/DABISbmdUwwujnwPNSjjI9WjKlkrk+JK0VZEm5PCb11Hi EtP7oD+qUTFnYSRNGYNqoxIOGxzf4R8xlVmVvhkwsnprLvdBRmpN7sd1mlIcRaQ5Qq EkitZ1qtawnaw== From: Arnd Bergmann To: Lee Jones , Daniel Thompson , Jingoo Han , Helge Deller , Artur Weber Cc: Arnd Bergmann , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Benjamin Mugnier , Krzysztof Kozlowski , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] backlight: lp855x: fix unintialized function return Date: Fri, 11 Aug 2023 15:15:53 +0200 Message-Id: <20230811131600.2380519-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann The function now returns an error code in some cases, but fails to initialize it in others: drivers/video/backlight/lp855x_bl.c:252:11: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] else if (lp->mode == REGISTER_BASED) ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/video/backlight/lp855x_bl.c:256:9: note: uninitialized use occurs here return ret; ^~~ drivers/video/backlight/lp855x_bl.c:252:7: note: remove the 'if' if its condition is always true else if (lp->mode == REGISTER_BASED) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Since this case should not actually happen, return the -EINVAL code. Fixes: 5145531be5fba ("backlight: lp855x: Catch errors when changing brightness") Signed-off-by: Arnd Bergmann --- drivers/video/backlight/lp855x_bl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index 61a7f45bfad84..ea4fa69e49a70 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -252,6 +252,8 @@ static int lp855x_bl_update_status(struct backlight_device *bl) else if (lp->mode == REGISTER_BASED) ret = lp855x_write_byte(lp, lp->cfg->reg_brightness, (u8)brightness); + else + ret = -EINVAL; return ret; } -- 2.39.2