Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3980066pxj; Tue, 15 Jun 2021 12:43:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6S42M0LmbDO6KI05PaBNPSwDa+tdtqA82ZQs/XvxeSP7oY8FsB5mTP49oQnbwvwXZS1Zp X-Received: by 2002:a05:6402:31ba:: with SMTP id dj26mr1464521edb.71.1623786206265; Tue, 15 Jun 2021 12:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623786206; cv=none; d=google.com; s=arc-20160816; b=kvPvimuN30g06BsM+fhiDs2xWH2gar91mId7Chj2SmZvG3+Mo9gLQfXsjBhmLWcY4Z 22UOdCAYuptK4R6W9LR4E+AHA7DreZTqN6pZ2gjlLNP4WKF5QibfGWHuSM+qUR37exYo iVeK0T/Vnc8ka0UV8WY4jTqhHq+rZYpmAbxbT3tCzLtKXMnrrm6tovnWLgO5mgaMGKmp Evw+dbtP2Qu4l4jaaI1XuJukhlwoR8KC2Ium4KSTMk00EHB97abQpXgfqCwZ2i8KS0MC jhsv7xZvN8QZlz+l7LJuw81912PkkMv2pbd9WQ7tWGZl83fGCpR21AB2MKzPaeAyEXFL NUaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=f6/i5s8IOzCUxNSyaYvlK4MuXc588RPfZhmyhczPhoM=; b=hH3cUoVzbEIvb/3Yq4nahSg4D5sVuybEbuOMMcNyVyJJnIzm5dYF0DobbqWI4zXkWG G0Dtgpx3n4PNGCMPLnSnWCaJoWbMUkp/BKGfWreI9KZSQhh6FDBihFqTP63jzGMy1bBN KWfTn7lwslvtoe3pxtyYfd2MKbYXdU9zIh2oe6ucsxQVx4+au7bUPbGK4KGQusNdbOKv n3mPtiy7gpdgxkg+C43ZGb388Cioecs/9evlWpJTSLOVIaGFYvtn7GieXu8wfAFVArp0 ll/n6UzObYh6H5yHCuuAWPOYVM9vjietN20ZDzSJRTpYNv/qmpsqlIHdwDCtz2FrFM3S mpTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WBPbfro2; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b20si14830023ejq.607.2021.06.15.12.43.02; Tue, 15 Jun 2021 12:43:26 -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=@gmail.com header.s=20161025 header.b=WBPbfro2; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbhFOToC (ORCPT + 99 others); Tue, 15 Jun 2021 15:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbhFOToB (ORCPT ); Tue, 15 Jun 2021 15:44:01 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 705BEC061574; Tue, 15 Jun 2021 12:41:55 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso317368pjp.2; Tue, 15 Jun 2021 12:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=f6/i5s8IOzCUxNSyaYvlK4MuXc588RPfZhmyhczPhoM=; b=WBPbfro2NwATm3JEz1Lg4fLKfLoX9TbPrF2j5G6OvxuIWu42YzPvjntCGsNjz+hlRd OCMLh+uE8u7spUQyarI/anBiSczOW3GVEkR4erCABZJ0Zgrzh9F3ZvxRFfimRRR0Y1cz rpPPtbnlrZyB3qU0YGCwDJnD1VIi6fejznBKQ0SYBb/NR23U/2hWucitbpc1nkw5XJna Ob9Q5ZDVZmU02N653mtAnfxUXiaK6YSNOU+bn/8I8oGryfv8nvn2KOPSIdxth6CwkWqJ PrVWhedUUw67dIhd/VZebA4YdrsD4tu6HlvlVMu4ViGGxbHpXl/zPjabcD26F5AnB9Gh KC2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=f6/i5s8IOzCUxNSyaYvlK4MuXc588RPfZhmyhczPhoM=; b=tF0+6iuzAUpr7oso4O8vNd65TBbSgBNfrlbSg9i/xK3nZBmTQU2RXRnq8+djJWeoAB kcHOUq5V6+O3+V4pDeQOz0WWDoNn6LaeVgronQ1E+ix1VrqePkur276xEu9A86Z/Aubc oLtcC5wPm5v++ZqvD8d0o6lzB2bZ4GechYjJTppeJTwOZHDs4XkVJ5/WRn41HOhmbpuF 56PF67Z6+LZ3FxTRyQ/hHXow5sQwZML5866MKYD7aGbfXz1wvoXGz7nCnzrLHeRGBbJ3 vXwo0Tz4x5+5sdfb7WY9WH/s5R+dI0LNqA2jFeq7fQAnZmKGjCRSIxwobrGuMzkPkiIJ uYNw== X-Gm-Message-State: AOAM533j2zkWYZPGdBa9FV0pJOFt+1CWkr+S9jjumhQxCBq3AhFbyLlo /uIlcSRFQQ8CHK0kqdxs0Zo= X-Received: by 2002:a17:902:b181:b029:fc:c069:865c with SMTP id s1-20020a170902b181b02900fcc069865cmr5728006plr.28.1623786114824; Tue, 15 Jun 2021 12:41:54 -0700 (PDT) Received: from google.com ([2620:15c:202:201:c700:bb55:c690:c756]) by smtp.gmail.com with ESMTPSA id n69sm16483124pfd.132.2021.06.15.12.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 12:41:53 -0700 (PDT) Date: Tue, 15 Jun 2021 12:41:51 -0700 From: Dmitry Torokhov To: Yizhuo Zhai Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Input: hideep - fix the uninitialized use in hideep_nvm_unlock() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 15, 2021 at 11:57:36AM -0700, Yizhuo Zhai wrote: > Hi Demitry: > > Thanks for your quick response, following your advice, a careful way > is changing the return type of "hideep_nvm_unlock()" from void to > int, and its caller "hideep_program_nvm()" also needs to add the > return check. > > If this sounds ok, I would go ahead to modify the patch accordingly. Yes, this sounds right. > > On Tue, Jun 15, 2021 at 11:15 AM Dmitry Torokhov > wrote: > > > > Hi Yizhuo, > > > > On Tue, Jun 15, 2021 at 10:26:09AM -0700, Yizhuo Zhai wrote: > > > 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. > > > > I do not think that simply initializing the variable makes the code > > behave any better. If we want to fix this properly we need to check for > > errors returned by hideep_pgm_r_reg() and hideep_pgm_w_reg() and exit > > this function early, signalling the caller about errors. > > > > > > > > Signed-off-by: Yizhuo > > > --- > > > drivers/input/touchscreen/hideep.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/input/touchscreen/hideep.c > > > b/drivers/input/touchscreen/hideep.c > > > index ddad4a82a5e5..49b713ad4384 100644 > > > --- a/drivers/input/touchscreen/hideep.c > > > +++ b/drivers/input/touchscreen/hideep.c > > > @@ -363,7 +363,7 @@ static int hideep_enter_pgm(struct hideep_ts *ts) > > > > > > static void hideep_nvm_unlock(struct hideep_ts *ts) > > > { > > > - u32 unmask_code; > > > + u32 unmask_code = 0; > > > > > > hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_SFR_RPAGE); > > > hideep_pgm_r_reg(ts, 0x0000000C, &unmask_code); > > > -- > > > 2.17.1 > > > > Thanks. > > > > -- > > Dmitry > > > > -- > Kind Regards, > > Yizhuo Zhai > > Computer Science, Graduate Student > University of California, Riverside -- Dmitry