Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1145473pxv; Fri, 9 Jul 2021 19:27:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw91KPsVGPN/pewHMJY5MK7HLCw/1LqxCsTb4rLMpJI8Ul3bIgkNNcreJQGj0mrooCVZBf9 X-Received: by 2002:a17:906:c08e:: with SMTP id f14mr3097082ejz.380.1625884054436; Fri, 09 Jul 2021 19:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884054; cv=none; d=google.com; s=arc-20160816; b=ADgtla8rwbPGtHF797mMGPwtT83QieoW4DGb8jw6A3zYjKG412Vy5jd8Jl2E9V6ApG c2lFUD0v2UCX+SBZGfy5Y4H20b/sui0HfUbvYHEtVBZwHb8yNE0xB+yb0LMy3OXAogKE 3vvIoDe45cGdJ0s+xJqn3PGa9BzNoc3Pv59Po72131K2bE3gj6iTdf4lHa7L01/lTrEX 43H074krw0biGsz0skJdk5eF56soNzirYTxcr3lXe7+fDII7TQLM/cA0Vilxo8+U+PKF 9YpdmSjVxjaoLgaEMKWuTCIG8RGUVyfS7hFlEVduEdf/n1fIEwcU8BFZgzxxuYjwR+k4 hU9g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KmAol5glX/PBHEh95r2F20K4CtRzv+/P9KPhdt71bM0=; b=OixKEtN04B6AJWUk9rrwqGswsCPUU/8BLeD6OSW7q3i4GMYcQn36ajJcAjy7jIV1bJ QmXKE1VsiZrpp4CgTtpCTqwVE3xWOsLmFtsIbGPZZh38syDU/qKlvMBy8hgeok5+92Ga 7rICccLuAaDggbraGDd2bvuVJdQYj+L+VIXhuAHCIcZk44/2IygSfcwGf+icB8/eTBtw 1wctmIQunVZW6jpVhR8ENIWbbWdlL/ffPduzSN9PkJNC7SO1FSACPznm//UySnOLVHas eYkMDMyGhGwhpUaVWZxvHxfC4rTwHZoDbkxtTQo4HIl4u7129NjeAXjhoFApTdTdEIMF uBhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rFBPbhIo; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r23si9749142edo.404.2021.07.09.19.27.11; Fri, 09 Jul 2021 19:27:34 -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=@kernel.org header.s=k20201202 header.b=rFBPbhIo; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233225AbhGJC2T (ORCPT + 99 others); Fri, 9 Jul 2021 22:28:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:42882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233445AbhGJC0p (ORCPT ); Fri, 9 Jul 2021 22:26:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A83FF613EB; Sat, 10 Jul 2021 02:23:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883835; bh=hwI9xTL2ebUdO0DmxdC1jpzwPPvsqSev3UsSzitDOfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rFBPbhIorIDBmBQmQ8UZa8EkrWgfFq09XfTwpxsPy432lalYp7Afp0MXy23EuUw44 cbbeN4BZOY7eYaLvYa/n+ZSwVS6ptUgJZWyoEHBXZI05sSJ/Ux3w+TCfani32yMFE0 gnziORBM0h2Ciip3OvgBViTBWHwam5daFJTICYc7+Xa5xiPynqxE3ciQ5J6ZnFT4c0 gY6dS24P2kY/0oNSESCFkpkZPjbxdn6/k6x0YPZI13NbWxGgB+ZIn8yK3QAmN2lnLU YLxff0l3wSRfbdVAVCutDnKwvSswHaHbxt57ydcyWmdskeOMpfar2vXE/ajYh7OQxe WiakyaBofHIXQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yizhuo Zhai , Dmitry Torokhov , Sasha Levin , linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 082/104] Input: hideep - fix the uninitialized use in hideep_nvm_unlock() Date: Fri, 9 Jul 2021 22:21:34 -0400 Message-Id: <20210710022156.3168825-82-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yizhuo Zhai [ Upstream commit cac7100d4c51c04979dacdfe6c9a5e400d3f0a27 ] Inside function hideep_nvm_unlock(), variable "unmask_code" could be uninitialized if hideep_pgm_r_reg() returns error, however, it is used in the later if statement after an "and" operation, which is potentially unsafe. Signed-off-by: Yizhuo Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/touchscreen/hideep.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/hideep.c b/drivers/input/touchscreen/hideep.c index ddad4a82a5e5..e9547ee29756 100644 --- a/drivers/input/touchscreen/hideep.c +++ b/drivers/input/touchscreen/hideep.c @@ -361,13 +361,16 @@ static int hideep_enter_pgm(struct hideep_ts *ts) return -EIO; } -static void hideep_nvm_unlock(struct hideep_ts *ts) +static int hideep_nvm_unlock(struct hideep_ts *ts) { u32 unmask_code; + int error; hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_SFR_RPAGE); - hideep_pgm_r_reg(ts, 0x0000000C, &unmask_code); + error = hideep_pgm_r_reg(ts, 0x0000000C, &unmask_code); hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE); + if (error) + return error; /* make it unprotected code */ unmask_code &= ~HIDEEP_PROT_MODE; @@ -384,6 +387,8 @@ static void hideep_nvm_unlock(struct hideep_ts *ts) NVM_W_SFR(HIDEEP_NVM_MASK_OFS, ts->nvm_mask); SET_FLASH_HWCONTROL(); hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE); + + return 0; } static int hideep_check_status(struct hideep_ts *ts) @@ -462,7 +467,9 @@ static int hideep_program_nvm(struct hideep_ts *ts, u32 addr = 0; int error; - hideep_nvm_unlock(ts); + error = hideep_nvm_unlock(ts); + if (error) + return error; while (ucode_len > 0) { xfer_len = min_t(size_t, ucode_len, HIDEEP_NVM_PAGE_SIZE); -- 2.30.2