Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3333460rwa; Tue, 23 Aug 2022 03:03:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR70eLMImz9aYZ3VOt2adwHwumkncFu/2jFcCm72jHnm+F65bf5ZS+lVbwSl3yTe0ZeT7ytD X-Received: by 2002:a17:907:97d5:b0:730:9eac:d965 with SMTP id js21-20020a17090797d500b007309eacd965mr15386601ejc.353.1661248990507; Tue, 23 Aug 2022 03:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248990; cv=none; d=google.com; s=arc-20160816; b=ZNV4y806mMBTh29zqurzOL/aLHyyp4Gdy62lahjv+dfE9MQgcx26VpqbLHTwZSIfb+ CJ4gqE13hHJPQC07HRKMUXEq9rDjC5khej/nNGFcWe38Qck4yGafz4JtYzTo9bQqwlg4 PopBToh+Z3AZI301NpSJwHgN0BKvISApAWOfXOwtol4EYaCosx9v29/ToKveXFfVOhsH bHKE55DbpcEQ1ClumOyomh20fiCf86Tr4QagkJnmsQbVraPtdZnMmzj82TQE8ibPJKIy OXuYhxyaXveKOmv84tehxAPJgibtsBKUKHJxaRSWKzlGLBQi9Egv24+xxiDm3Zyn1uIQ Z+pA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pap8TgUUJdx9w/5XZoYAsPt7HWhYV/scAHiOe1x/Vo4=; b=W37xlqI/a/6JKlDiJJ5aQT54Rp4pMMxPb2s/p5lJjJB+NFPCDiq2iEyClIfXMSUXSm 8cmNP2ofHN1TX+OaTV9pFUDy0OM3/MRf9q/RxEbGJFb05UY5fKp+/5sSA/XK+fc5YBFH FkU0vcwsPhGYauHRNz3v6kk9Ux+3OaDWevu+LbcKJ5OMg/fLagCn/LNtfY3lRjzmRR5F SQO3bGXCxle/y4sE+wdlZBnIpDZzz6HVTwPWvGDDOj9baiB/xsJEiEB5jDwycobODXx8 +4Cb8ANhgHGSHqBdX5bntfd1scI9irxZ7kRkBcGP050CKW9I8ZzSG7+eUiYUh9SM1uw/ UozQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="LgN/ROKs"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d6-20020a50f686000000b00440e4be2c8bsi1644589edn.507.2022.08.23.03.02.41; Tue, 23 Aug 2022 03:03:10 -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=@linuxfoundation.org header.s=korg header.b="LgN/ROKs"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232330AbiHWJxA (ORCPT + 99 others); Tue, 23 Aug 2022 05:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351913AbiHWJvA (ORCPT ); Tue, 23 Aug 2022 05:51:00 -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 5C4149E2D7; Tue, 23 Aug 2022 01:45:41 -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 A5E03B81C4D; Tue, 23 Aug 2022 08:44:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE16CC433C1; Tue, 23 Aug 2022 08:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244289; bh=DR1snfRLybVmdH1tOb3/8khLmueGUFR93/TihdxZuYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LgN/ROKslviYay73BT5PFe37Z9xKdY2gAOnXXsG0u/s01EwSs8zZao1wFMn/HcEAN 5Mg/opfFZC7GP7x5/PP36cYr6wT2bCrp6CPi8VHfniifTFx7/PjMNKZpqnSFWAY888 P6bFUI+sO2wmOP7MOxJTasQ7Ethb7l4TKrSh9igI= 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.15 068/244] Input: exc3000 - fix return value check of wait_for_completion_timeout Date: Tue, 23 Aug 2022 10:23:47 +0200 Message-Id: <20220823080101.347387951@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 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 <= 0 is ambiguous and should be == 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] = { 0x67, 0x00, 0x42, 0x00, 0x03 }; int ret; + unsigned long time_left; mutex_lock(&data->query_lock); @@ -233,9 +234,9 @@ static int exc3000_vendor_data_request(s goto out_unlock; if (response) { - ret = wait_for_completion_timeout(&data->wait_event, - timeout * HZ); - if (ret <= 0) { + time_left = wait_for_completion_timeout(&data->wait_event, + timeout * HZ); + if (time_left == 0) { ret = -ETIMEDOUT; goto out_unlock; }