Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756652AbbESPPN (ORCPT ); Tue, 19 May 2015 11:15:13 -0400 Received: from rrw.me.uk ([93.93.129.10]:54634 "EHLO rrw.me.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756631AbbESPPL (ORCPT ); Tue, 19 May 2015 11:15:11 -0400 Message-ID: <555B5380.90601@kynesim.co.uk> Date: Tue, 19 May 2015 16:15:12 +0100 From: Richard Watts User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 002/003] Attempt to cope with device changes and delayed kobject deallocation References: <555B5305.9050506@kynesim.co.uk> In-Reply-To: <555B5305.9050506@kynesim.co.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1193 Lines: 35 Avoid attempts to use device parents with zero refcounts Signed-off-by: Richard Watts --- drivers/base/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 21d1303..207fbb2 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -762,7 +762,13 @@ static struct kobject *get_device_parent(struct device *dev, spin_lock(&dev->class->p->glue_dirs.list_lock); list_for_each_entry(k, &dev->class->p->glue_dirs.list, entry) if (k->parent == parent_kobj) { - kobj = kobject_get(k); + /* Be careful: an old parent may still + * be in this list awaiting deletion, despite + * having a refcount of 0. We don't want to + * add it here and then have some other thread + * delete it. + */ + kobj = kobject_get_unless_zero(k); break; } spin_unlock(&dev->class->p->glue_dirs.list_lock); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/