From mboxrd@z Thu Jan 1 00:00:00 1970 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 CBA8C16F0D2 for ; Mon, 5 Aug 2024 23:32:29 +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=1722900749; cv=none; b=c8U13/gl0NjUIqS67RzmQFHPsQxIKhMnV2KAHN7hKPXs9pA40CN29uxrLQH1RVaKkbrRHDJbd/peDA6My2xKKwKBob00bzDc7IEAwLffLHe+cXy8tL9iuPjk35P4JETfD6qgIio8uXDzIZ2F5DvfYkDoqd6UHqpSk0IUTVFY2n0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722900749; c=relaxed/simple; bh=S75KKTJFpLT0HDPsOjwDXaDIq5d6qUG2IWEf46QlNTs=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kWE6RD+buPZYM0vxx9gl1L3UKuQgLc9EbxqbSrLxmqKani6C944H91nHA0TlqEnO1KyeCKQmVfbSaugR2r+/DYQDEPaitgvlZsd00VkNsj/aAYNsDlyy/f+pY0U5vOkKmfmZk+6qNqj+toYYGQaqu9RidTqNgu5ZVy+Vw8rjLdU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PNK68lsn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PNK68lsn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7612DC32782; Mon, 5 Aug 2024 23:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722900749; bh=S75KKTJFpLT0HDPsOjwDXaDIq5d6qUG2IWEf46QlNTs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PNK68lsnbpZ0loO0x/ooylDd7qjQbCm2W3T4hASYpSYgrwbgvyWeeRRShLPd6NEK3 +VdT7zYIXQA3OH4rScxAEOEOsz7DEsVOOx5XwccFM2TBt5A1cyZAPrHd5V7vFu/VzG wkCn92boe+jCo+n9La9SGsBGjj+qOHv1jjwa2QTzicc2/8Ad74pODUQb4mzVcATl14 JD0geuyC7r8AW4mFvm3RnnaTO5pHGYKd+diAq2OX/VN0A+/zxgf4Py7D6BMVTdMpPj SwLg3ilgUh2r5L3er+CHVUy6ThS9xMbDp/8S0wWkEHrqNkqx0cPT9vIqZ70B9Fi5T/ VA1huwZMuAN6w== Date: Mon, 5 Aug 2024 16:32:28 -0700 From: Jakub Kicinski To: Joe Hattori Cc: andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org Subject: Re: [PATCH] net: dsa: bcm_sf2: Fix a possible memory leak in bcm_sf2_mdio_register() Message-ID: <20240805163228.16956875@kernel.org> In-Reply-To: <20240802085411.3549034-1-joe@pf.is.s.u-tokyo.ac.jp> References: <20240802085411.3549034-1-joe@pf.is.s.u-tokyo.ac.jp> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 2 Aug 2024 17:54:11 +0900 Joe Hattori wrote: > bcm_sf2_mdio_register() calls of_phy_find_device() and then > phy_device_remove() in a loop to remove existing PHY devices. > of_phy_find_device() eventually calls bus_find_device(), which calls > get_device() on the returned struct device * to increment the refcount. > The current implementation does not decrement the refcount, which causes > memory leak. > > This commit adds the missing phy_device_free() call to decrement the > refcount via put_device() to balance the refcount. Please add a Fixes tag pointing to the commit where the problem was introduced and make sure you CC the maintainer of the driver. -- pw-bot: cr