Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1845139lql; Wed, 13 Mar 2024 09:38:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjXcc/id/WbVMDwC+JCg3+8nQnELEyadgPEoJdNXV2daH8mDC++ghLBWgn0eOK5Oa40tuG9wgu95Y3Dm1rPJf5loUPSfeu1HrF1Fmynw== X-Google-Smtp-Source: AGHT+IFuqV6CNOE7R+T40YgxLvA1h8V7xW3+i5Fp0WPS+nRnoT9t/sNwKBSczJog5I81kkhH2gOS X-Received: by 2002:a05:6a21:19b:b0:1a1:49be:c81d with SMTP id le27-20020a056a21019b00b001a149bec81dmr4317223pzb.33.1710347904170; Wed, 13 Mar 2024 09:38:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710347904; cv=pass; d=google.com; s=arc-20160816; b=dPwpfx18YXmCjnL8MA7+rhjK/7+NSM9T+6bU40CbNCPqYIYKHejK29lkFG2eKRt4jT jxZlWoOjaMDf032CyOfQBRBKz3Cx5Z0gtpjGroiogB82M+9VytXt8qT/VXyB6JzqlPkF Yy4x+3VnZBYDS9NYfFB3p5A1xTIazhp4eQz9MtA1caGHaRROu+lInro2vF4hI23KLZgJ 9hVFUWkmkqr6GbyeJscP09HIFFXs2fU6xEHxtGxJhPyoQ7/fHda9lVMDnbA3s1km4FR9 vrYNl18VUEWNXgRTdCckows26ui5uH2d/NefFlxfB5zI976OozGMLXjAsaXsbnFZaevv evPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=M4wu8CrS08UKE6qw1tU+afEZGP9jzZ6wVvgHfoOAcCk=; fh=Q3mXMmV4A1pi7D4LJ1eVG2lobrmAt7Z9OcoaFzeOPVg=; b=k9n/fPPkTY88s/WbVaE3+BX/0FBLOeahTdo+GJs+0N59PJhayGhUgZx9spUbiWmArl P+voAPfE5OGCz8zHymt268z38WELCBpJe7NWsJdnyKyjucPTC3+9HsDSG74SRTrJMeUR IAYoZMypmWXADZcJyMeae2kIIlK7otokoxSFjyAH7vEU1aDVWcKS2gDnUJZpLd5fozQ0 mjN1lMiBF0J7JEmyXPDifngmjkIdGcvBIKRw5+kJA7c0ZSOwTBQSgsxfVizr+3kLG4hS esLKGf8CZT5+9oGe8TGVWBDz1L/swLrxwoc2hvKPzUmdPRZLym91TqJsrLIdPR60AfOt Aj4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T4jKOea2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101749-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101749-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o18-20020a639a12000000b005e468bd4cadsi9479351pge.787.2024.03.13.09.38.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 09:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101749-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T4jKOea2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101749-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101749-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 54AC9B2360E for ; Wed, 13 Mar 2024 16:35:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0889E56B7F; Wed, 13 Mar 2024 16:32:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T4jKOea2" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 260475917C; Wed, 13 Mar 2024 16:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347571; cv=none; b=lWdRSmME5NnBFdXTYuZAqCePO3b4Du7hn5cyD/RAgn/lTwRU6Mf7lqz7RUOuASRwuWoE+lUBhkeryA8KgmVTRXmjql03oNyWASWi/JxZJHWoB/8k7IdTTbhVrH/LfWuJG5El57bCtQypryPlp7YHukKmV8qeIv8RlLVBKcWD1z4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347571; c=relaxed/simple; bh=oot0yLFZ/cSpMIaV7o+cb5pLc+I+X2NT5B3fpxJtVmQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IM396lpvu3sBulr52UDoEOnS4eP1TGrUTrtm0dIpQIqcAKL2eC0FAaHIXay4Dvt5Ru3WmK9P+e16tzK8c2Kp2hFD4CgJuxYel/MuGTYKrfliEQVzxn7Q05uMrNfXzDUHDDifBevtFaNv8kBuTuM4kNoNrPo5/FYhipCYyIEmH30= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T4jKOea2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28D6AC433A6; Wed, 13 Mar 2024 16:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710347571; bh=oot0yLFZ/cSpMIaV7o+cb5pLc+I+X2NT5B3fpxJtVmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4jKOea26BLQDDhL9Zn1tQAIjXavkYM8z8dcIGAoQxh52Fte12kpUqvN6ylkSl2f5 myoedHlBRi1uDVokWQm8oseubLYovMb5jlU2i9vlUYLsT2k6tq2Qw8MSliSMiYJKUY nicFPbnCUax8b2aoOBAshDpv/39RRgVHNMaHP7KQpfOAyefKl7T2FsBIfxvqAJ1bKA AnIf9vJSjP07Q7SsnXh23yB5E55+m6wepPPkCxa5l/20GlDNgk+G6gG08ct1H90RVY penNc0ubzVUwmqgTQqnq4nWg/fnscdHtawuya3MJdcIJSrj96jE1fOKTuh8aejC9X3 HENBFFJ/yeIEg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oleksij Rempel , Jiri Pirko , "David S . Miller" , Sasha Levin Subject: [PATCH 6.7 10/61] net: lan78xx: fix runtime PM count underflow on link stop Date: Wed, 13 Mar 2024 12:31:45 -0400 Message-ID: <20240313163236.613880-11-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313163236.613880-1-sashal@kernel.org> References: <20240313163236.613880-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.7.10-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-6.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 6.7.10-rc1 X-KernelTest-Deadline: 2024-03-15T16:32+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Oleksij Rempel [ Upstream commit 1eecc7ab82c42133b748e1895275942a054a7f67 ] Current driver has some asymmetry in the runtime PM calls. On lan78xx_open() it will call usb_autopm_get() and unconditionally usb_autopm_put(). And on lan78xx_stop() it will call only usb_autopm_put(). So far, it was working only because this driver do not activate autosuspend by default, so it was visible only by warning "Runtime PM usage count underflow!". Since, with current driver, we can't use runtime PM with active link, execute lan78xx_open()->usb_autopm_put() only in error case. Otherwise, keep ref counting high as long as interface is open. Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") Signed-off-by: Oleksij Rempel Reviewed-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/lan78xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index a2dde84499fdd..f0fb9cd1ff56c 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3137,7 +3137,8 @@ static int lan78xx_open(struct net_device *net) done: mutex_unlock(&dev->dev_mutex); - usb_autopm_put_interface(dev->intf); + if (ret < 0) + usb_autopm_put_interface(dev->intf); return ret; } -- 2.43.0