From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752743AbdJFJ11 (ORCPT ); Fri, 6 Oct 2017 05:27:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51402 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751846AbdJFJ0n (ORCPT ); Fri, 6 Oct 2017 05:26:43 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Whitehead , Tejun Heo , Gwendal Grignou , Sasha Levin Subject: [PATCH 3.18 29/35] libata: transport: Remove circular dependency at free time Date: Fri, 6 Oct 2017 11:25:09 +0200 Message-Id: <20171006092403.973296011@linuxfoundation.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171006092402.810400570@linuxfoundation.org> References: <20171006092402.810400570@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gwendal Grignou [ Upstream commit d85fc67dd11e9a32966140677d4d6429ca540b25 ] Without this patch, failed probe would not free resources like irq. ata port tdev object currently hold a reference to the ata port object. Therefore the ata port object release function will not get called until the ata_tport_release is called. But that would never happen, releasing the last reference of ata port dev is done by scsi_host_release, which is called by ata_host_release when the ata port object is released. The ata device objects actually do not need to explicitly hold a reference to their real counterpart, given the transport objects are the children of these objects and device_add() is call for each child. We know the parent will not be deleted until we call the child's device_del(). Reported-by: Matthew Whitehead Tested-by: Matthew Whitehead Suggested-by: Tejun Heo Signed-off-by: Gwendal Grignou Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/ata/libata-transport.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/drivers/ata/libata-transport.c +++ b/drivers/ata/libata-transport.c @@ -223,7 +223,6 @@ static DECLARE_TRANSPORT_CLASS(ata_port_ static void ata_tport_release(struct device *dev) { - put_device(dev->parent); } /** @@ -283,7 +282,7 @@ int ata_tport_add(struct device *parent, device_initialize(dev); dev->type = &ata_port_type; - dev->parent = get_device(parent); + dev->parent = parent; dev->release = ata_tport_release; dev_set_name(dev, "ata%d", ap->print_id); transport_setup_device(dev); @@ -347,7 +346,6 @@ static DECLARE_TRANSPORT_CLASS(ata_link_ static void ata_tlink_release(struct device *dev) { - put_device(dev->parent); } /** @@ -409,7 +407,7 @@ int ata_tlink_add(struct ata_link *link) int error; device_initialize(dev); - dev->parent = get_device(&ap->tdev); + dev->parent = &ap->tdev; dev->release = ata_tlink_release; if (ata_is_host_link(link)) dev_set_name(dev, "link%d", ap->print_id); @@ -587,7 +585,6 @@ static DECLARE_TRANSPORT_CLASS(ata_dev_c static void ata_tdev_release(struct device *dev) { - put_device(dev->parent); } /** @@ -660,7 +657,7 @@ static int ata_tdev_add(struct ata_devic int error; device_initialize(dev); - dev->parent = get_device(&link->tdev); + dev->parent = &link->tdev; dev->release = ata_tdev_release; if (ata_is_host_link(link)) dev_set_name(dev, "dev%d.%d", ap->print_id,ata_dev->devno);