Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp66711imm; Tue, 21 Aug 2018 23:44:16 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzSRysb9/AJ5YxZla3WvQMhhuCMcJTIE2821s6x8qMVNvOY7an0aww823neHECztOZaC36V X-Received: by 2002:a62:c4c3:: with SMTP id h64-v6mr56207849pfk.39.1534920255997; Tue, 21 Aug 2018 23:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534920255; cv=none; d=google.com; s=arc-20160816; b=uICrWF5sdSKL3adlJRlPDOKUHWw6ejXYHrB9VcCLokbXpDwMoxiz7rc54dfKLNg77m +CuvE1dxNMOORLefU8eSKlZ+AJN15ZFalsfuUNVaIrsNMuS3f/i8iJCPUJWIBRp+fGhf agxSI3lUDnVPRYFdRg3o9gNwPDwX46swAgCEzI3ey7Ys/j/hRKxeMob2IpBxMiO1K1At KZPM0UTA54ppy1bIY/nkZjNw2jmpLg4BFUTbn9xC9mW2VpAus+s0VI7zwo2PVK/yKuBg SdAOMZyBnD9oPdSwTkCrTwo1HVrAxB2ZSziTpRofc8M7DpWUbvwjHOxSGBvkqFxpVaEX tLdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=UW4ZsrCPjamJHLSA41RLPjO22f4v73OtGL5f6u3pQts=; b=B5NOZ7cxuyQNul8PlbT+sPKU8f5HCF/vm6BdHLTwrZUKIR86Rf0u4r9q1Y6Je+BPyF GHSOHe6PLdrYZJuES+JntAwlo73UF3l0QdQ61xSgr0IRrFVzw2cUXqI50NVmXTovEK2t MJBnKF4Ooo7mTFs9unt9kdeLJLHH6iDNHZDHZ5RQ74g4xNbVjw2xf37TGAtovCrtKytA qRsePRZ0Ts1tFcjT95JuoIEl9lid8b3KtzOmJ/wC4G7zUssA9x37u/J1pK6ZPfkAfXOf ju+FLwCawPsClO35059XXjDUiW1Qyngp8sOwjwBUD67fUiwnQO6tSIEafVjsjbuivXZ2 R0SQ== ARC-Authentication-Results: i=1; mx.google.com; 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 v4-v6si887361plb.400.2018.08.21.23.44.00; Tue, 21 Aug 2018 23:44:15 -0700 (PDT) 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; 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 S1728066AbeHVKFI (ORCPT + 99 others); Wed, 22 Aug 2018 06:05:08 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:42001 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726983AbeHVKFI (ORCPT ); Wed, 22 Aug 2018 06:05:08 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsMph-0006pY-D9; Wed, 22 Aug 2018 08:41:33 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1fsMpf-0000vn-52; Wed, 22 Aug 2018 08:41:31 +0200 Date: Wed, 22 Aug 2018 08:41:31 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Anton Vasilyev Cc: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: Re: [PATCH v2] serial: mxs-auart: Fix potential infinite loop Message-ID: <20180822064131.2qy3ntri7rdypmfo@pengutronix.de> References: <20180806164346.9986-1-vasilyev@ispras.ru> <20180807105905.18264-1-vasilyev@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180807105905.18264-1-vasilyev@ispras.ru> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 07, 2018 at 01:59:05PM +0300, Anton Vasilyev wrote: > 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 > --- > v2: mistype in patch as result of combination of different fixes. > Change comment and leave enum type. > --- > 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 76aa289652f7..27235a526cce 100644 > --- a/drivers/tty/serial/mxs-auart.c > +++ b/drivers/tty/serial/mxs-auart.c > @@ -1634,8 +1634,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); I wouldn't have added the comment, but the code change is correct. Acked-by: Uwe Kleine-K?nig Thanks Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |