From mboxrd@z Thu Jan 1 00:00:00 1970 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 B2604C433FE for ; Tue, 21 Dec 2021 19:44:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241891AbhLUToZ (ORCPT ); Tue, 21 Dec 2021 14:44:25 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:37626 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbhLUToZ (ORCPT ); Tue, 21 Dec 2021 14:44:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=dEFjK55pXFeqtv/q14sfwoR57qhngxFbFwSK8SuJ9ps=; b=F++MUPoXxSLqCMRP1MXy5o9qSi MsLWE019fuHEjU5pRXBjassKxm87DPMZlsy1YguKFKDbRTCJbFFS96vAYr+jGTwxFWjP3Z6bLO6E1 9ZFK9pP+BgiFHJs23nbUBxRRqWXouP1VXsls1rIGheXGUj9nx/mmA7e2AtLmiZ4wIkUA=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1mzl3c-00HA8n-31; Tue, 21 Dec 2021 20:44:20 +0100 Date: Tue, 21 Dec 2021 20:44:20 +0100 From: Andrew Lunn To: Pavel Skripkin Cc: davem@davemloft.net, kuba@kernel.org, linux@rempel-privat.de, robert.foss@collabora.com, freddy@asix.com.tw, linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] asix: fix wrong return value in asix_check_host_enable() Message-ID: References: <989915c5f8887e4a0281ed87325277aa8c997291.1640115493.git.paskripkin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <989915c5f8887e4a0281ed87325277aa8c997291.1640115493.git.paskripkin@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 21, 2021 at 10:40:05PM +0300, Pavel Skripkin wrote: > If asix_read_cmd() returns 0 on 30th interation, 0 will be returned from > asix_check_host_enable(), which is logically wrong. Fix it by returning > -ETIMEDOUT explicitly if we have exceeded 30 iterations > > Fixes: a786e3195d6a ("net: asix: fix uninit value bugs") > Reported-by: Andrew Lunn > Signed-off-by: Pavel Skripkin > --- > drivers/net/usb/asix_common.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c > index 06823d7141b6..8c61d410a123 100644 > --- a/drivers/net/usb/asix_common.c > +++ b/drivers/net/usb/asix_common.c > @@ -83,7 +83,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm) > break; > } > > - return ret; > + return i >= 30? -ETIMEDOUT: ret; I think the coding style guidelines would recommend a space before the ? I would also replace the 30 with a #define, both here and in the for loop. Andrew