From patchwork Tue Nov 18 14:33:07 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lennert Buytenhek X-Patchwork-Id: 9420 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id A1C86DDE04 for ; Wed, 19 Nov 2008 01:33:16 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751931AbYKROdL (ORCPT ); Tue, 18 Nov 2008 09:33:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751917AbYKROdK (ORCPT ); Tue, 18 Nov 2008 09:33:10 -0500 Received: from xi.wantstofly.org ([80.101.37.227]:48805 "EHLO xi.wantstofly.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751234AbYKROdJ (ORCPT ); Tue, 18 Nov 2008 09:33:09 -0500 Received: by xi.wantstofly.org (Postfix, from userid 500) id EA4197FAB1; Tue, 18 Nov 2008 15:33:07 +0100 (CET) Date: Tue, 18 Nov 2008 15:33:07 +0100 From: Lennert Buytenhek To: jeff@garzik.org Cc: Bryan Wu , netdev@vger.kernel.org Subject: [PATCH,RESEND] phylib: fix premature freeing of struct mii_bus Message-ID: <20081118143307.GA12255@xi.wantstofly.org> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit 46abc02175b3c246dd5141d878f565a8725060c9 ("phylib: give mdio buses a device tree presence") added a call to device_unregister() in a situation where the caller did not intend for the device to be freed yet, but apart from just unregistering the device from the system, device_unregister() does an additional put_device() that is intended to free it. The right function to use in this situation is device_del(), which unregisters the device from the system like device_unregister() does, but without dropping the reference count an additional time. Bug report from Bryan Wu . Signed-off-by: Lennert Buytenhek Tested-by: Bryan Wu --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 6671e2d..df06301 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -135,7 +135,7 @@ void mdiobus_unregister(struct mii_bus *bus) BUG_ON(bus->state != MDIOBUS_REGISTERED); bus->state = MDIOBUS_UNREGISTERED; - device_unregister(&bus->dev); + device_del(&bus->dev); for (i = 0; i < PHY_MAX_ADDR; i++) { if (bus->phy_map[i]) device_unregister(&bus->phy_map[i]->dev);