Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1842154pxb; Mon, 13 Sep 2021 06:44:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXP+BG+DmkTUp71BXyGjt9GQB3EoYk0CGoT22UcNCnrjS8MCqnbsnEXhammG1neIsHPFhP X-Received: by 2002:a92:b705:: with SMTP id k5mr5231863ili.224.1631540698306; Mon, 13 Sep 2021 06:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631540698; cv=none; d=google.com; s=arc-20160816; b=IvDW2IF527Qu02u8fTX9CbBKzdkhVVbcMzMcwXRbw2kcSG7ZeoqkYbVKG0H8DlKV/h evwi1ZcacscF9sQ/deLBcfDKetwsy2HYZwnYbglnnRMAnmulAIDMYC14BmRk2IwCQk8f 7xevesC4x/Y5mtV9W0yq6mK4oxgufvbpPo6/yDRoncti4JdBq+lp/N7hEKy5pmBPzoAK +HlORagCEstdhUvZ2Zm0MncQTxJCOTKuB9oWOipPJwfYySTqcO50L8aSjPFVk/NuKX7X eWlXI0jzPf9Hnf1Rag+Tt1lUvO534Cnzs+bFcOtHmqgcyZgMe8fZHj/7XSRG4Mj2Wx8F YI8w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3vOZFb4u8FQZr/fHaq9ymg87RAFJm3EhJ9Ugk6RupBI=; b=jQWaE2qNv343Vklx5wrq0GERki5v7JUChN76Biw5fW89Ko7YLZOeRkkt+2hWFxx77i 0P5h1ZAnboeMFD3fVwED5xOJQ5nDDBdRLw17J8gBZFPUHxxG+sT8Q0Sld7I7CRdpe42m UfruNFkLx8uIA8vczmx84PVAnwId7IltKSCB0sIwAaGbph5wUyXxONz4Dy73eqBffs2z mSPbOhosVnQ5kgTjW+noXwwn89S2w476Tb44pZuUgrlJ8Gp4bvgoGnk/98/Nn4Vep9o+ mYXjweo8oFIGbCxuAC2n7Zsx8YOZHgMWJN1u1TcOqBLDVrgf4KMOmi5BRU9N4vE/FyCM kWbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ai6K0hJq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r18si7355186ilc.134.2021.09.13.06.44.19; Mon, 13 Sep 2021 06:44:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ai6K0hJq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243453AbhIMNmc (ORCPT + 99 others); Mon, 13 Sep 2021 09:42:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:35706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241958AbhIMNg7 (ORCPT ); Mon, 13 Sep 2021 09:36:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9CD1F613A8; Mon, 13 Sep 2021 13:27:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539677; bh=VXE0TY40WKo3a6aWGZjd72SExSfJt/UYR8dPRxbWiTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ai6K0hJquSw0pLz0/JBBrvF4tSHWh7zzSwSXQB8wZnSmNhB/Gia3kS853jiBuNkWE qUkVpx4T85/YKD1SltABoLCJXFlvy1OE+T8pncXcjEi5eKHYcHBLc4iYj/ycZcgWf9 LGuJVY7EQsFRrHtP3LgF8I0kliR05J8dPiM1KORk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yizhuo , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 099/236] media: atomisp: fix the uninitialized use and rename "retvalue" Date: Mon, 13 Sep 2021 15:13:24 +0200 Message-Id: <20210913131103.716053859@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yizhuo [ Upstream commit c275e5d349b0d2b1143607d28b9c7c14a8a0a9b4 ] Inside function mt9m114_detect(), variable "retvalue" could be uninitialized if mt9m114_read_reg() returns error, however, it is used in the later if statement, which is potentially unsafe. The local variable "retvalue" is renamed to "model" to avoid confusion. Link: https://lore.kernel.org/linux-media/20210625053858.3862-1-yzhai003@ucr.edu Fixes: ad85094 (media / atomisp: fix the uninitialized use of model ID) Signed-off-by: Yizhuo Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c index f5de81132177..77293579a134 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c @@ -1533,16 +1533,19 @@ static struct v4l2_ctrl_config mt9m114_controls[] = { static int mt9m114_detect(struct mt9m114_device *dev, struct i2c_client *client) { struct i2c_adapter *adapter = client->adapter; - u32 retvalue; + u32 model; + int ret; if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) { dev_err(&client->dev, "%s: i2c error", __func__); return -ENODEV; } - mt9m114_read_reg(client, MISENSOR_16BIT, (u32)MT9M114_PID, &retvalue); - dev->real_model_id = retvalue; + ret = mt9m114_read_reg(client, MISENSOR_16BIT, MT9M114_PID, &model); + if (ret) + return ret; + dev->real_model_id = model; - if (retvalue != MT9M114_MOD_ID) { + if (model != MT9M114_MOD_ID) { dev_err(&client->dev, "%s: failed: client->addr = %x\n", __func__, client->addr); return -ENODEV; -- 2.30.2