Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1873728lql; Wed, 13 Mar 2024 10:24:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWexijgI0jHY7V6M1F2TvYwg2VWupdhPpz6/t5vi67zXxUiPE7DUQhNBrdy4mLKu5imRszF997bJziSm0Pxe8GGBgShr+MUshFQ7ssmMw== X-Google-Smtp-Source: AGHT+IE6nZY7kClBr/F6EZJJNm1UyLZ6YgGX7Od/eaI72VoV3ODN6ukn7JQx9MdummLdIvCIh8nw X-Received: by 2002:a17:907:6a17:b0:a45:8b6d:42c9 with SMTP id rf23-20020a1709076a1700b00a458b6d42c9mr3078557ejc.23.1710350652472; Wed, 13 Mar 2024 10:24:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710350652; cv=pass; d=google.com; s=arc-20160816; b=NuB7ghx1G9izcyEgW4OWi6GrLY1U5yn7ED99QbNVzLVjOw6HPZbEKhBI0UH0Nz/DIj SScEFzZKoaMIZILp3KoHW9e/CZXsWlTdhAy+M4HRUu1z5Xoo8dy8ouAlp51Zx6TSndy5 Dx9H79mvKgshv8qnIWJKllfjTR+1Wg4+UT4Rj4QRhseCyx1H79qp9ORIa23SNWCRtOwZ WGbFFr9hF38nzRyvFNE0Q+DXbGwtqH75l1Bb4Mf67l7hraZ0N8XcyPzg+tmga9GNp4HO q9QMOPan82jm1QK9I4lRJmUYiy667CdS2W1T5hUWplrgP7qCd4CHEEnWwt408ewu5w5c 88KA== 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=Vy6OwIB9spZShnUaKmHanNWydu3OxzthjQE0IgJ74G0=; fh=Q3mXMmV4A1pi7D4LJ1eVG2lobrmAt7Z9OcoaFzeOPVg=; b=jiQqU/p7anrbJRC9x5LDd5EkYqgMqgICwhjN5YzXAHbFYb3slaiosT6LW+LXSRlJAW L9j9j0JufbnndpuQN1JOqpZ24znGe9unpPvgH89pcgZxfEjMIaoBcAONuL14TKkALKwT 88jJHSSmCltc08PQ/MIjk8lKwg7BLyKe46oGx38bKfuBsGOPYoglzJAv5C83tl2+Hh+M 5VHdffIz1LjtvI6mDyRRF4Do4f3Ub4nM78lJLmM2Ge7VJfgCrHYCOwwt5xYAecuAryqa yWJPDLUj+QU2R/f71QmN5VIcc8lcBOY0EjpCrbvfpO/dr3Zyy06q8DBbSnOXoGc99Whb kddQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QdVz807g; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101943-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id jz19-20020a170906bb1300b00a4643bbf213si1786056ejb.635.2024.03.13.10.24.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:24:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QdVz807g; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101943-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5F9141F2419E for ; Wed, 13 Mar 2024 17:21:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52AAD62800; Wed, 13 Mar 2024 16:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QdVz807g" 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 72737627E8; Wed, 13 Mar 2024 16:42:30 +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=1710348150; cv=none; b=FrkATvDBd3Ppxg5ZJXcbBK+04O1MCXIF2RJOl+YEDCoKybAnUPCpPcmGUfpy0aJz/c9sXEh+Tbl7NVrTI2HWdn+3FgfrL1zvBG1R28t7WbzB5q7pi2L8EsqZBIYMe1WEcdXV/JWs/45UH+jFk+dhZAPgxeRx9C69Ze5zkNX+qeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348150; c=relaxed/simple; bh=ZnVYI0EVRMPAR8YuEzTHJ8BKEfsGMglMjd5MZe0BcTY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sKlfmIqyZBzvPp/tLoh0OX85Jg9F67GTRWUlZZJgv5v7z4o05cfb7GKl/vDoK+ksWrVbbqWOW1Kfu4jsefQOcq3Mjq3LlnNnNDlelIiiA9uqVYsfFN2gdF+vxuVfASuhAVprUmB52a+9xvuVGD9HfrnR4xiVki4f8mF/gj42n44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QdVz807g; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D227C433B1; Wed, 13 Mar 2024 16:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348150; bh=ZnVYI0EVRMPAR8YuEzTHJ8BKEfsGMglMjd5MZe0BcTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QdVz807gDjqumUkrg7+XL1zFfu2v43PCeqQlpbXVHDB/tTzHmGVVqckBY8keOhV0E Jlq7DM/aFgGwnWx0mlDRzHrkBSqbctC2qEL6OXKnaDd59HiH9MBMOSaCS1tFYZofjH 22hcdLvbOM6l33Dld5UJg3o5i1vwop7sKTiv0TBwXPqj1aikFueR+d9j52PGMdmn1S 1Jkh5B3UbfF2BTzNM0fAPpeUK6uqnzvKQGoGuvMEh7ZzUF8k1EyfBkerPEufy3qMjp ZonZnLHDrTw1e5yXbA7rF/v3OnF6eBOCc9erJKmkzW97erEyj6CDbA1RWBEdEUiqZM RWf/cZa4vcFsA== 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 5.15 03/76] net: lan78xx: fix runtime PM count underflow on link stop Date: Wed, 13 Mar 2024 12:41:10 -0400 Message-ID: <20240313164223.615640-4-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-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/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+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 c8b42892655a1..77cb30259dca7 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -2960,7 +2960,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