Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4048814ioa; Tue, 26 Apr 2022 15:53:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpUFNopjig9LMOAb86pAtmCza33RSdtpL4Hzp0gjTP9E3VBOc7DPTVBJAQVnqDBrH7Ql9J X-Received: by 2002:a17:906:9749:b0:6ef:bc52:1f94 with SMTP id o9-20020a170906974900b006efbc521f94mr23539560ejy.666.1651013623272; Tue, 26 Apr 2022 15:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651013623; cv=none; d=google.com; s=arc-20160816; b=tfggBfw+kAJPWQ4VBCWTorvkiIVtVGhAmfSPxpRWDG5ZyJLnPKjy7TeoFaZHFAG7mD YXsIwRE6UYzoG9zdIaUc1RJxTn5GLDXyQ+BeGp0wDguchu4KYX2hFQHJ6Gk13vkvHf8k cSUws2wS6+V+uJdFwbiqSC7cbJi5zBNrjco0crpkYdOUDsRfUS/y5nUidd0HzJZUca4l 9UOPGlov1dH4r4xQSVc9bjIXcrSvCzHwcUhKmMSMjSY9BXv+xARico/SZo0v6R84tA29 vCbGmTIQs3Jlk30UlfH0xkro4NghunVo3RDyYyHh5R8klGEXITyHKF+OUyJWHUJXYc4f zrKw== 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=RpA3G+JS+/v41bEmdGtfoyVlPFsfssNyc0dlzgR3yLc=; b=opID2G54BLVLAa/UwrSxRgDbq7v15AkagnfdG5rd1b0BqOOtt75vSFUCvCfO61Vuc9 dDcV6JXF9giufrwbPRhg0tsfBXzdirqK8NCXv2y98o07fU3PySt9WusJj7ks64kU4dXp h20kXwqWAlMTPWIm9nMawkhVMcFkQOKifHfBaRGN0TT9Lld9fbzn7Oh5V/naYNaHwxG7 WQbpRIL8+5gJNcO3crGSJfvGZhkYtaTWHsXfMWXPScXGXbNYdYMn6xxg2XrEfTx34DHG nRertkhAWzPG3qpAxn0ZGoJOZvjt52MZP7zV3w/ULk/5idu5JdWGYJpT9tTLA3z1+u50 kzrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UG0C0Nrn; 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 d12-20020a170906640c00b006e86c3056c2si16883860ejm.33.2022.04.26.15.53.20; Tue, 26 Apr 2022 15:53:43 -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=UG0C0Nrn; 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 S1346632AbiDZIuN (ORCPT + 99 others); Tue, 26 Apr 2022 04:50:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345874AbiDZIjk (ORCPT ); Tue, 26 Apr 2022 04:39:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9450793A9; Tue, 26 Apr 2022 01:32:13 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 3B6356186E; Tue, 26 Apr 2022 08:32:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A881C385A0; Tue, 26 Apr 2022 08:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650961932; bh=avBp042OE31BMRDyzTLJ+AKx4VLhedoWFD+owDAlhws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UG0C0NrntO5mQyEsIh7nUGPs7OaqZ336c4Jr3sJiOWQVbE3n8OrizUxFkQZIwCoFn I54mR/yXaruuK6DjtutzWmS5Zq1PLxWGqQyds7PSnTW7JrlKTP7pvLXH8PPTNG9l1g ie6usWZPTXYcKEjRMJWsMsdIYiSyUmwNA0J0eJrQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dima Ruinskiy , Sasha Neftin , Naama Meir , Tony Nguyen , Sasha Levin Subject: [PATCH 5.10 17/86] igc: Fix infinite loop in release_swfw_sync Date: Tue, 26 Apr 2022 10:20:45 +0200 Message-Id: <20220426081741.703088248@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081741.202366502@linuxfoundation.org> References: <20220426081741.202366502@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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 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: Sasha Neftin [ Upstream commit 907862e9aef75bf89e2b265efcc58870be06081e ] An infinite loop may occur if we fail to acquire the HW semaphore, which is needed for resource release. This will typically happen if the hardware is surprise-removed. At this stage there is nothing to do, except log an error and quit. Fixes: c0071c7aa5fe ("igc: Add HW initialization code") Suggested-by: Dima Ruinskiy Signed-off-by: Sasha Neftin Tested-by: Naama Meir Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igc/igc_i225.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_i225.c b/drivers/net/ethernet/intel/igc/igc_i225.c index 553d6bc78e6b..624236a4202e 100644 --- a/drivers/net/ethernet/intel/igc/igc_i225.c +++ b/drivers/net/ethernet/intel/igc/igc_i225.c @@ -156,8 +156,15 @@ void igc_release_swfw_sync_i225(struct igc_hw *hw, u16 mask) { u32 swfw_sync; - while (igc_get_hw_semaphore_i225(hw)) - ; /* Empty */ + /* Releasing the resource requires first getting the HW semaphore. + * If we fail to get the semaphore, there is nothing we can do, + * except log an error and quit. We are not allowed to hang here + * indefinitely, as it may cause denial of service or system crash. + */ + if (igc_get_hw_semaphore_i225(hw)) { + hw_dbg("Failed to release SW_FW_SYNC.\n"); + return; + } swfw_sync = rd32(IGC_SW_FW_SYNC); swfw_sync &= ~mask; -- 2.35.1