From nobody Thu Dec 18 13:01:08 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 285CDC32796 for ; Tue, 23 Aug 2022 08:27:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243499AbiHWIZc (ORCPT ); Tue, 23 Aug 2022 04:25:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243564AbiHWIVW (ORCPT ); Tue, 23 Aug 2022 04:21:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 576BB6FA07; Tue, 23 Aug 2022 01:12:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 64BC0B81C38; Tue, 23 Aug 2022 08:12:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B77ECC433C1; Tue, 23 Aug 2022 08:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242352; bh=DR1snfRLybVmdH1tOb3/8khLmueGUFR93/TihdxZuYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bXDTyLk/X/Tzzcr6NSYuOede184p2iFK4n3xMHHymw0WqoANCLM+XGKvpecDIC25v Twr+UiPl31xW4/1TkGaH3ku272ESgkbycgWhlia+Ee2zt0aGik/pyh7XkyDkAc63v8 LlJ4J0cCEZwipuu+yYoOrtCAw5DdEEsRxuHoM4X4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Dmitry Torokhov Subject: [PATCH 5.19 102/365] Input: exc3000 - fix return value check of wait_for_completion_timeout Date: Tue, 23 Aug 2022 10:00:03 +0200 Message-Id: <20220823080122.468747566@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miaoqian Lin commit 6bb7144c3fa16a5efb54a8e2aff1817b4168018e upstream. wait_for_completion_timeout() returns unsigned long not int. It returns 0 if timed out, and positive if completed. The check for <=3D 0 is ambiguous and should be =3D=3D 0 here indicating timeout which is the only error case. Fixes: 102feb1ddfd0 ("Input: exc3000 - factor out vendor data request") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220411105828.22140-1-linmq006@gmail.com Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/touchscreen/exc3000.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/input/touchscreen/exc3000.c +++ b/drivers/input/touchscreen/exc3000.c @@ -220,6 +220,7 @@ static int exc3000_vendor_data_request(s { u8 buf[EXC3000_LEN_VENDOR_REQUEST] =3D { 0x67, 0x00, 0x42, 0x00, 0x03 }; int ret; + unsigned long time_left; =20 mutex_lock(&data->query_lock); =20 @@ -233,9 +234,9 @@ static int exc3000_vendor_data_request(s goto out_unlock; =20 if (response) { - ret =3D wait_for_completion_timeout(&data->wait_event, - timeout * HZ); - if (ret <=3D 0) { + time_left =3D wait_for_completion_timeout(&data->wait_event, + timeout * HZ); + if (time_left =3D=3D 0) { ret =3D -ETIMEDOUT; goto out_unlock; }