Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5237237ybl; Tue, 27 Aug 2019 01:19:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyef8pw7NseLaPLUEMxtDU6aKYhD24kf7XUp3ddJYA15sHsJkFMwoOqsNZDq06fdxXQctVJ X-Received: by 2002:a62:1703:: with SMTP id 3mr24712877pfx.118.1566893952746; Tue, 27 Aug 2019 01:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893952; cv=none; d=google.com; s=arc-20160816; b=iUXd4XtF05AJNyIMpoAZDa5RDajWD4b3U0qA+jQKM0KKMSsCDf7yvV+CXF9tewZRVo /4K9mnchxiO36cTkKt1ZTrj/Ww1fT6w+gj4oudV2T8NVgVzJJ4hP46dR1NFHIrJFbZOm ZA2rmbj6XzG59/zksIIDwWoeuR/n9FuaU9e9t7l0afQnfG65dspi/Q1yZfVjRiqNiuIi 6NyxSQ+k8fK43Y/tvkRj7YQoQEtWbGfHG+YcxJJG4ioLXPXrvNoJac+grDiHE7av+8yW p1NaaZhRMR5IgDyzeX3bNva7TutrYdGyN5xgNE4rghBs1aauv8yQ+NerX55nZbWM9+nz dFpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HLdXyULGWIqAHyVStYhJKxPZI3ZM8/jPlE6czlcqgTY=; b=gAq33AoHFb8nOywj88f1r7TYqePQ5N3udQeI8+Xzqr8ekTLRWDMgjV3gCYYRXSxlcY LjFlBN/VT580gDBxaUJ7Dq0NPuJ5ugQT+hk5yja0t4EtZ9tAOPEyhJJEcH4Q0ATsRovY vycdL96ITRmZJeVOeCV4NdF+hBz/qwjdf+3m3EhPXwr7gQdC7ebtsYtXKO/9bMMD+6zd 4kkx5dYPKZFhb+0nZ4/qPHtQge2O1GGWd9Bwg0KmzvAVSnitpsFa5uD6mwI57ukugQaR seheOZnRBo2BrWcaA8ZN6xu/Ja9IOL2POiZW4evuymNcSMIXTjGvgMeXbAr1YL3PS/uq OP2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IMsOdXm9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u70si11462044pgd.1.2019.08.27.01.18.51; Tue, 27 Aug 2019 01:19:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IMsOdXm9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730060AbfH0Hy3 (ORCPT + 99 others); Tue, 27 Aug 2019 03:54:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:46000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729536AbfH0HyZ (ORCPT ); Tue, 27 Aug 2019 03:54:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75E2B206BF; Tue, 27 Aug 2019 07:54:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892464; bh=oocRzilriowvGwyzD4I+sBipUlHRbO+/i4RBfBsJ4EA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IMsOdXm9QxkcR0LmzRECRHsl/h8cWDxiGEDQi7d3o8B78vIXTgRxWLe4NZsyOn0mg xSv5d5ZeuPAAZT8vWyo6gsIrktzcBkX5P3B91ZgWUzh+aQ78AlOyaYItoHTGIA0xqH 8XGJXeMFrrx+aLZKuAqXwRqocLpkrHTY9vGBVLfo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Kelley , Thomas Gleixner Subject: [PATCH 4.14 56/62] genirq: Properly pair kobject_del() with kobject_add() Date: Tue, 27 Aug 2019 09:51:01 +0200 Message-Id: <20190827072703.716791086@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072659.803647352@linuxfoundation.org> References: <20190827072659.803647352@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Kelley commit d0ff14fdc987303aeeb7de6f1bd72c3749ae2a9b upstream. If alloc_descs() fails before irq_sysfs_init() has run, free_desc() in the cleanup path will call kobject_del() even though the kobject has not been added with kobject_add(). Fix this by making the call to kobject_del() conditional on whether irq_sysfs_init() has run. This problem surfaced because commit aa30f47cf666 ("kobject: Add support for default attribute groups to kobj_type") makes kobject_del() stricter about pairing with kobject_add(). If the pairing is incorrrect, a WARNING and backtrace occur in sysfs_remove_group() because there is no parent. [ tglx: Add a comment to the code and make it work with CONFIG_SYSFS=n ] Fixes: ecb3f394c5db ("genirq: Expose interrupt information through sysfs") Signed-off-by: Michael Kelley Signed-off-by: Thomas Gleixner Acked-by: Greg Kroah-Hartman Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/1564703564-4116-1-git-send-email-mikelley@microsoft.com Signed-off-by: Greg Kroah-Hartman --- kernel/irq/irqdesc.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -277,6 +277,18 @@ static void irq_sysfs_add(int irq, struc } } +static void irq_sysfs_del(struct irq_desc *desc) +{ + /* + * If irq_sysfs_init() has not yet been invoked (early boot), then + * irq_kobj_base is NULL and the descriptor was never added. + * kobject_del() complains about a object with no parent, so make + * it conditional. + */ + if (irq_kobj_base) + kobject_del(&desc->kobj); +} + static int __init irq_sysfs_init(void) { struct irq_desc *desc; @@ -307,6 +319,7 @@ static struct kobj_type irq_kobj_type = }; static void irq_sysfs_add(int irq, struct irq_desc *desc) {} +static void irq_sysfs_del(struct irq_desc *desc) {} #endif /* CONFIG_SYSFS */ @@ -420,7 +433,7 @@ static void free_desc(unsigned int irq) * The sysfs entry must be serialized against a concurrent * irq_sysfs_init() as well. */ - kobject_del(&desc->kobj); + irq_sysfs_del(desc); delete_irq_desc(irq); /*