From patchwork Fri Dec 4 08:20:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 337736 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp53963ilb; Fri, 4 Dec 2020 00:22:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJy928s4TulcaGtJ3Su9WUOgxy3E47wYfq+kPqdjEwQDF5/5VyyCeM9OBJewLu/++BAGIQS/ X-Received: by 2002:a05:6402:10ce:: with SMTP id p14mr6484827edu.12.1607070134416; Fri, 04 Dec 2020 00:22:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607070134; cv=none; d=google.com; s=arc-20160816; b=js24kLqustMs/hZSsM7/K1O7zbi5uL427V6ydZkpl1EGPikh6bs/C06yM3mzwJdFZd 4VIRa2TSZYh4nMiCFa6FoW395dFTKuVc1jSmJmswkTmwtNKX/TmXwQtsLxwIB0uRkkoJ eMPrVRukMpfi8ksNlXnkdx1hv+vhGJ2F/C3vpsk3ThsnoEnhRp+uipakf6Nli9YFFI6a 2iENfDLz5UGr0ZbU4wVZYmVX1nxrq22grE6MxqFKKYgCnfcItMKcFZU/F7+dcZ0fRGgf sgWYQqlCFuKKECN4MSnLxA1NPEWDxCkQhMuiyDJR88HiTAtqrEVba0ulWG+/GNuebEr9 A09w== 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; bh=sRZLa1I8vMYDqE+td8MFGaX68bMipHwVJQwxNgXKrk0=; b=ctwWdZVNWlbLB/jVDPS0725VAv3m/D+QlUSvyrVDNq35IwUfyFgtWxPPbYT1lLH/XA S42vcyvYoQTo/VE1buyO2NDIeozNqMpDn4p8arb7aTq/pL1OFyh0slcRNQzJ2Lz+S2sX tBvGedwApcQHPjszMT92m7hyxqlwvL8Fb1GteZq5G+nJr/ClRZmehF63lEai/ofpx469 AwZpA8i9QoNiRXK2gk/xpn8U4Zeffv4C26X70hsTaI1gFVGJpsEYK+L5bJIW7srFp/FZ FOMuxqaxKMv4jBnCnzVyxUkZcUUx4Xtjyh9g2O5O32kAUel343VRwkz5c8xOO9/GTP/U Hx3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si876548ejm.641.2020.12.04.00.22.14; Fri, 04 Dec 2020 00:22:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-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 S1728983AbgLDIVY (ORCPT + 4 others); Fri, 4 Dec 2020 03:21:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:33886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbgLDIVY (ORCPT ); Fri, 4 Dec 2020 03:21:24 -0500 From: Arnd Bergmann Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: Dongchun Zhu , Mauro Carvalho Chehab , Matthias Brugger , Nathan Chancellor , Nick Desaulniers , Andy Shevchenko , Sakari Ailus Cc: Arnd Bergmann , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, clang-built-linux@googlegroups.com Subject: [PATCH] [v2] media: i2c: fix an uninitialized error code Date: Fri, 4 Dec 2020 09:20:14 +0100 Message-Id: <20201204082037.1658297-1-arnd@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Arnd Bergmann Clang points out that the error handling in ov02a10_s_stream() is broken, and just returns a random error code: drivers/media/i2c/ov02a10.c:537:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (ov02a10->streaming == on) ^~~~~~~~~~~~~~~~~~~~~~~~ drivers/media/i2c/ov02a10.c:568:9: note: uninitialized use occurs here return ret; ^~~ drivers/media/i2c/ov02a10.c:537:2: note: remove the 'if' if its condition is always false if (ov02a10->streaming == on) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If streaming is already on, leave it that way and return success. Suggested-by: Dongchun Zhu Fixes: 91807efbe8ec ("media: i2c: add OV02A10 image sensor driver") Signed-off-by: Arnd Bergmann --- v2: - return success instead of -EBUSY, according to feedback from Dongchun Zhu - remove incorrect advice from warning message citation --- drivers/media/i2c/ov02a10.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.27.0 diff --git a/drivers/media/i2c/ov02a10.c b/drivers/media/i2c/ov02a10.c index 391718136ade..8683ffd3287a 100644 --- a/drivers/media/i2c/ov02a10.c +++ b/drivers/media/i2c/ov02a10.c @@ -534,8 +534,10 @@ static int ov02a10_s_stream(struct v4l2_subdev *sd, int on) mutex_lock(&ov02a10->mutex); - if (ov02a10->streaming == on) + if (ov02a10->streaming == on) { + ret = 0; goto unlock_and_return; + } if (on) { ret = pm_runtime_get_sync(&client->dev);