Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp131099ybc; Mon, 18 Nov 2019 21:51:21 -0800 (PST) X-Google-Smtp-Source: APXvYqx6pt9kmY6Cg6qYwePI3dQUm1nsl7rRaRQdNcOc2KOrhWeWr+iKBb5tdWGOUz2g/J/fq1sB X-Received: by 2002:a17:906:32d0:: with SMTP id k16mr31240982ejk.155.1574142681628; Mon, 18 Nov 2019 21:51:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574142681; cv=none; d=google.com; s=arc-20160816; b=q6h6oaVdTrw58wANkRAeGEknf8mORrCB7uloAGx99FQ9EY2OsQ69K7H41hEr4S0nia /iliyro7fuhGiFEsRLhrA44u/wgmEieD/dqPbYG3xtvyt8WRImd5U7ARU+MHx0UBv6TH 4sdVirtwROckmVmj9wCrc1F9csse6zFduf1kL6j4YWQm/ZGfNK0O/kGQQdfaO/N8wYcf e9Z8F7XVphJOVpqFG7nI7ZBQbLY+1elQHU3iijhJTW/uAxyiNv6w5oyxnQv91roxPach 1NblfBjf1iP4xu6PuFAJYFbjatS66ELqkrjy9ybO4YsMl7HJa+mQfOWKWkcLM2VLJCwp zrmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YLEfKzBFHNO6T9hiM3PLkQ49x/a3ZomvLdAVfrn5vYI=; b=BYkBlH+Mfse35R+HLFhdmreOMwL4rMeTDWFDUtSrfrm9tS5zQXKFvrp2pGIiSNS1Yy yyVg/bUPui0XKXDDM8Pf0BZUiEzpobLPjE871Vq5Q1cowvFhkE4IMtWifnqNGsgms3TX U4CcIgggaf6vPc6LKaScqlixUsMW+1oC4u2lcQCKAuHlsta2zqmkh67irbFsmU+ARf7D empwPXH3YdDqyL+b/8zGF2sS487CSFtrTh3Ajap0be/BE0/q89uMFx2m3RQOAaBmliVU 6rnIswxP+a5CaWFsPr76e3ZyMhH3zxICeqxuM0N/7S6JF4iozUdqCia10rLJiB881uIj Os/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MSi9icl6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hh7si13171224ejb.57.2019.11.18.21.50.58; Mon, 18 Nov 2019 21:51:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MSi9icl6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730995AbfKSFty (ORCPT + 99 others); Tue, 19 Nov 2019 00:49:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:46774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730977AbfKSFtw (ORCPT ); Tue, 19 Nov 2019 00:49:52 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CFC5420721; Tue, 19 Nov 2019 05:49:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574142591; bh=oDKOZKsGlOSOwbHZ/0xDL00iTc9xm4wYxZZxvU1I6Pc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MSi9icl6diIxTztkx04q+QfB0mjB9fj5jhjcajI9GeNr/VIBw8WhScBJwuknapO/R YsEqQmnxjDK57blqSfH559mfpnAIPkW0nQC0L33lPJqT1//ENL22b4MqTjrna+/ZTi HxrBCAFkc+7ZiIALaoAycgkCJ8sSpOWVt8KFOoa0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Vasilyev , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Sasha Levin Subject: [PATCH 4.14 134/239] serial: mxs-auart: Fix potential infinite loop Date: Tue, 19 Nov 2019 06:18:54 +0100 Message-Id: <20191119051330.894516003@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051255.850204959@linuxfoundation.org> References: <20191119051255.850204959@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anton Vasilyev [ Upstream commit 5963e8a3122471cadfe0eba41c4ceaeaa5c8bb4d ] On the error path of mxs_auart_request_gpio_irq() is performed backward iterating with index i of enum type. Underline enum type may be unsigned char. In this case check (--i >= 0) will be always true and error handling goes into infinite loop. The patch changes the check so that it is valid for signed and unsigned types. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev Acked-by: Uwe Kleine-König Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/mxs-auart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index 673c8fd7e34f6..e83750831f15e 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c @@ -1638,8 +1638,9 @@ static int mxs_auart_request_gpio_irq(struct mxs_auart_port *s) /* * If something went wrong, rollback. + * Be careful: i may be unsigned. */ - while (err && (--i >= 0)) + while (err && (i-- > 0)) if (irq[i] >= 0) free_irq(irq[i], s); -- 2.20.1