Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6410638rwr; Mon, 1 May 2023 23:19:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41DENvkR6yDToiH2tob/gYJXqKcLr/ZZ9dXOXwyQs7VWrmnJ8kb4JDSDRWXcPX7lEBKS0n X-Received: by 2002:a05:6a21:380e:b0:f0:4664:ad53 with SMTP id yi14-20020a056a21380e00b000f04664ad53mr13793161pzb.48.1683008392821; Mon, 01 May 2023 23:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683008392; cv=none; d=google.com; s=arc-20160816; b=OB/8oLlNpEb1S7bmhXdE/9UpUJTLiu+NhzJBskt3HbVVFwvBBHLWiWlp2sqAaOjyeg hrD/bcta8Li3/+vXNcE2D659PlJBhMYCvh2UApxrRIA5ADq1b4Y8CmNitVEPDITHKCnw dph2cnAQyzay1AZTZTp9wSbFhsrsmo3sw+cPy0f5kCuWnlayjSN05B1gQY9Vzwe+j8fm CXyICds+KCo/Gh4fNmODe8mR89uo7ZDV9WdKVVbrcyZnspg+4odAUnwJ7D6WjSBobDMh HIV1M/bNyuSrMhmtKFa20WCDbDhkj/dV6rTeVH2xkdfZeQihp/07sl//jrbxom/kfIqg xsfg== 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:feedback-id :dkim-signature:dkim-signature; bh=ba9RAZXvdpWufyFprLLb/WROhkE667HyPHaNEAwBidY=; b=obTJ3PGzQObqdJP7Vr+sqj+dhGnbcmzG4gs/9Ugi1VVrw7erjvtKv/ojYjMrNJXPLZ Cyt0TczaIj1pRt7fxpI+AzXO93xceEJK8MoH2B7CH8lhCbodvCJ+re9glev3v+0RsNEI Vzsc9jHq74D9NCvMYPYG5GpZiP78rE2wPVqPwjLxjeCp+Y6igHdiNEi3g7C+ggh4zDOD s3WCTPzw8WzgCImhRLM/2rp7q1XvYGgSkAcWt5WciXJA2FK//VAevWfeM9n0Jw/guUSw acDfbsrNGWR4fCsWe1OhrqNhgThRsQEeVO+Yvzygdz5QHFWNrHQJDyRHVwcqnC2MZdgg t+/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@who-t.net header.s=fm2 header.b=KwZoHc70; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Z2tzdSGW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a17090acf8300b00246eebc793esi31111511pju.180.2023.05.01.23.19.38; Mon, 01 May 2023 23:19:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@who-t.net header.s=fm2 header.b=KwZoHc70; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=Z2tzdSGW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233439AbjEBGFn (ORCPT + 99 others); Tue, 2 May 2023 02:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjEBGFl (ORCPT ); Tue, 2 May 2023 02:05:41 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CD312D63; Mon, 1 May 2023 23:05:40 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 6864C32009E5; Tue, 2 May 2023 02:05:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 02 May 2023 02:05:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=who-t.net; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1683007539; x=1683093939; bh=ba 9RAZXvdpWufyFprLLb/WROhkE667HyPHaNEAwBidY=; b=KwZoHc703NTc7c4P7h jYw0SQGJ97yeFQb+PPK9RL6CpaWsIXvfqACmFqYcHLLmKLvFNAMrhhc3ZsLbQNRc R8EQqDkApomkfyrJoHcaOlzD+0fMoLd8A/fxniE1pxQmdO7MxitgIGHUMLNIz523 k7lFWgzX6ZCUUCA+2NJ46jlFu5G2hBf7uO4t47WkpUILNFr/lg91Xs4EsGx2qDt8 /Ir4IviFDfrkYRatTSHru6kSVPlXR/CXr4uASPbYDEgMP6mbRL2TVONZ272zSLQK hhsXVcqCKo341SQC/ZBauX/sTT6puaMoV130uY+s6hEqQ8aPpoZRIgNqMn/cHTD1 D6og== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1683007539; x=1683093939; bh=ba9RAZXvdpWuf yFprLLb/WROhkE667HyPHaNEAwBidY=; b=Z2tzdSGWvQd+rd7pSZIsSVlqWZDpF 2HxVXeblldW9jI46ZXNsjXL7SddAJbvfPyOcIRi8q/g9jF2pPxyio36WjEOCtOFJ 9shepKPPcf+vsZiVNyX8z/Zyqkz8crTqQpzKbYy58hhuAz2WYGS6zOsquURFJfSs bZFx2pummEDd6bCSu95XHz9lbvJilyWPMDdLt/d65gzucVkkPn/jd8lZiHa/3eqy Siq9Qs2rwsOLpCXhYEtAz9kqoMucwtMp74LJlDTky3L51cTVjju3tcdDUiHyeTCy lqpNqbRQfM58r1BA0kaA8hFTpbFhNGpdhL36a4FNx2iKZgIH6gq9rgY7A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedvhedguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefrvght vghrucfjuhhtthgvrhgvrhcuoehpvghtvghrrdhhuhhtthgvrhgvrhesfihhohdqthdrnh gvtheqnecuggftrfgrthhtvghrnhepkedvkeegheefjefgvddufffhveehjeffvefgiefg kefhudeifedugfetudfgtefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepphgvthgvrhdrhhhuthhtvghrvghrseifhhhoqdhtrdhnvght X-ME-Proxy: Feedback-ID: i7ce144cd:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 2 May 2023 02:05:37 -0400 (EDT) Date: Tue, 2 May 2023 16:05:31 +1000 From: Peter Hutterer To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, Teng Qi , linux-kernel@vger.kernel.org Subject: Re: [PATCH] Input: avoid calling input_set_abs_val() in the event handling core Message-ID: <20230502060531.GA857155@quokka> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 01, 2023 at 06:01:19PM -0700, Dmitry Torokhov wrote: > input_abs_set_val() can nominally call input_alloc_absinfo() which may > allocate memory with GFP_KERNEL flag. This does not happen when > input_abs_set_val() is called by the input core to set current MT slot when > handling a new input event, but it trips certain static analyzers. > > Rearrange the code to access the relevant structures directly. > > Reported-by: Teng Qi > Signed-off-by: Dmitry Torokhov Reviewed-by: Peter Hutterer If git grep is to be believed, this is the only use of input_abs_set_val. Maybe removing that function is an option? Are there external drivers that rely on this (instead of sending an event)? Cheers, Peter > --- > drivers/input/input.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/input/input.c b/drivers/input/input.c > index 37e876d45eb9..f791d14ecf23 100644 > --- a/drivers/input/input.c > +++ b/drivers/input/input.c > @@ -190,6 +190,7 @@ static int input_handle_abs_event(struct input_dev *dev, > unsigned int code, int *pval) > { > struct input_mt *mt = dev->mt; > + bool is_new_slot = false; > bool is_mt_event; > int *pold; > > @@ -210,6 +211,7 @@ static int input_handle_abs_event(struct input_dev *dev, > pold = &dev->absinfo[code].value; > } else if (mt) { > pold = &mt->slots[mt->slot].abs[code - ABS_MT_FIRST]; > + is_new_slot = mt->slot != dev->absinfo[ABS_MT_SLOT].value; > } else { > /* > * Bypass filtering for multi-touch events when > @@ -228,8 +230,8 @@ static int input_handle_abs_event(struct input_dev *dev, > } > > /* Flush pending "slot" event */ > - if (is_mt_event && mt && mt->slot != input_abs_get_val(dev, ABS_MT_SLOT)) { > - input_abs_set_val(dev, ABS_MT_SLOT, mt->slot); > + if (is_new_slot) { > + dev->absinfo[ABS_MT_SLOT].value = mt->slot; > return INPUT_PASS_TO_HANDLERS | INPUT_SLOT; > } > > -- > 2.40.1.495.gc816e09b53d-goog > > > -- > Dmitry