Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp151103pxb; Mon, 13 Sep 2021 15:36:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynw1VQ9/r5Zc581KUPkuty232q0CQScNdA45IVZGMF4T6GqchK+cJKFHWOAWL/Zc8nvdVs X-Received: by 2002:a5d:8894:: with SMTP id d20mr8691313ioo.4.1631572575894; Mon, 13 Sep 2021 15:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631572575; cv=none; d=google.com; s=arc-20160816; b=JqQUpiAosw31TZSqN5BRWaRWbTkQkTjz6X2LrONUXYUoUWPqF7vdxahBJ/HGpSnCaV +WNxA2wrFDhUeDM0W6/63h3JpD/5s9RzOfdJfOBPZtjvPvvpnt8ub/jYm5PvmrT0GXX8 nbPdqG0fXJFslYDIjZecBVdQobSteo8w7Cw3BSYj4oxT1NaQTEkCIhXxHbS05piuoppe lxoy3YfoP6ukE1mQ9eF92Zdb7OvIZBk0J4YTk3T4XERKdC3GlniiGjv/acoJzYGQutBW QGIQG78RlzvYJQYnUOPIOCIPZJssCjQc5qAemlqCQjh2DxBFyjSZRRU0wiDUSc4mA111 WgZg== 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=x6EZDhGFqsuFFvX1dmmDGlBPnjO81wjPreniEIPrpgWSHP5wnERDIIyKkmXjSzmeDC wkSG/MQ4/ect34iUpKEpo9rFiU5JyJD9QyN20O5KUwkmeF/xT1K5rmRHVRoXpMA8JneT 0M+mgDyo/HZ+Prdbwq1Ja9OqC2HR3m5EJEnb+6IJcgaIFWFsrsc58bgKN381mVKVC5RT PiruxtF0OaujdCYdNzfxdKFBJVT/E7DIhV/kdSQRrdRKOpRezZCEcGd7Ogh1/gHAKw6M 4lhA5yD9G0GTlDD2UJ9oYD3S+U2F2dH3tF7z6tdWpSMTCT3Zl9hTXE85O6xOzi/N/iDy A52w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x1hfxv7U; 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 d9si1408316ilv.97.2021.09.13.15.36.02; Mon, 13 Sep 2021 15:36:15 -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=x1hfxv7U; 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 S245629AbhIMODH (ORCPT + 99 others); Mon, 13 Sep 2021 10:03:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:46012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245228AbhIMOAj (ORCPT ); Mon, 13 Sep 2021 10:00:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 759B6610A2; Mon, 13 Sep 2021 13:37:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540251; bh=VXE0TY40WKo3a6aWGZjd72SExSfJt/UYR8dPRxbWiTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x1hfxv7UEkRyTAtCoU4EczeKrDvugT5sSDVvrAy9MpizkvR2AYqkZvEoAfbEf/8un BJm7aHmxjsAd7QalSMYcEJ64DF860GzMlsG0Y7xSfRTmiZuqRguUGYOgO2wekVu8/t oWTRqFcRRiWr6DzIEArVmhB6CT0ImQkbm6F4CPbc= 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.13 115/300] media: atomisp: fix the uninitialized use and rename "retvalue" Date: Mon, 13 Sep 2021 15:12:56 +0200 Message-Id: <20210913131113.278268747@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@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