Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1148100pxv; Fri, 9 Jul 2021 19:32:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBStHzEUM+aE7VrvtEOp1kmT4h8lA7SlKYbvYd4L/+HuBJjOvMN2OewckWPwc4uge7YkPl X-Received: by 2002:a17:906:28c4:: with SMTP id p4mr12317516ejd.302.1625884376051; Fri, 09 Jul 2021 19:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884376; cv=none; d=google.com; s=arc-20160816; b=w4GnPD1XoS8IjcrvRllVz+dzv3kqd31WjbJP5yCdW/LaAnv/ZrfRLWVFPzdlUGgIr9 wh5Hy9R6pml14GO7EtTkLbNdWlvv9+4pSMJq204o8mmFyZFCxmvEZ0G8oQRa45LckpEk E4j/EQ5SFTKz/mXpDXiMvLfEdW0rhyqAqKBhzQZ3KOUz4db3AV6G0kKjLXW2uvr8/tHV CYomi7DFRCEBnGBVA47Z9njA4ZESyN5PP6CRSc3BTZadnW50frFiNrF4s/6GTqIVpLXm EoZ60s22y+8Z8b8G2hIGB6X3gPXFzL76seQZ48LpyFCR+/Li/nWYpQuzsjYI1xlyCIhl HOFg== 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=eILF+Gs88W/l9PKWq4kX5w1dSfLrYY5Yhiq/54ruQonIoFJgAR2SslmCl+0ECYFxFG FNTc8l20aYf5BWb16JmU5dHEb9fNq8aO4bv1ed0XyhF71jKO+cUkzgja71ByWhVcfiX/ ECJhL00fEW4l6/pEKfeRqMWoLYvRyY6izNcqL/zO8UceI1imkZG2oYng5t0Shf41768c TBs2M3Kgu3uCnFM2IOa7CRn4eBDtrAxTuX15TN36FdoMfXuJJHkgGgXqQhdiP6c/dSJK u5TpUMgjrlsCVKKgA3f7nFfJL5ZMJUL6sktSqKLQcUaAMCzKqKiDyGOu/2xElw6rwmm0 R7Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=klgRP1EV; 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 s1si8310753ejs.746.2021.07.09.19.32.33; Fri, 09 Jul 2021 19:32:56 -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=klgRP1EV; 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 S233958AbhGJCd6 (ORCPT + 99 others); Fri, 9 Jul 2021 22:33:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:42616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234512AbhGJC3e (ORCPT ); Fri, 9 Jul 2021 22:29:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A0DF1613F7; Sat, 10 Jul 2021 02:26:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883998; bh=hwI9xTL2ebUdO0DmxdC1jpzwPPvsqSev3UsSzitDOfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=klgRP1EVgAIw91GXIzTdXzzKumL7cKM1O4YGc1NuHXXQncY07YQQfdd6C6tMiekp+ X+dTvEnWkqxTIpOvbYWVKglBbB84iT6HxrJHeklHqf9a6XlgqfKpqUwIkKmixqrhes 9R13d26KUxIcZK+zBRZy9bIudZMZU3zOklsdvDv52Hf/FZVcYOwtHpEp6LtHeDiIkf q5ABhP/JFtVjFKPEvv5nU2BCfIz7k2AU8N2WH/ixyuisJ+MYeqRjPB+kgqdzvaiIb+ uETh+gAZg/7fofqQMlqLXM7ofdmASTp95bjOF7fiNLPISBbnKz8U7RAYy67O71HhSa xjLrZ1L3ZvPjw== 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.10 73/93] Input: hideep - fix the uninitialized use in hideep_nvm_unlock() Date: Fri, 9 Jul 2021 22:24:07 -0400 Message-Id: <20210710022428.3169839-73-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022428.3169839-1-sashal@kernel.org> References: <20210710022428.3169839-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