linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Michael Kelley <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, mikelley@microsoft.com,
	gregkh@linuxfoundation.org, hpa@zytor.com, mingo@kernel.org,
	tglx@linutronix.de
Subject: [tip:irq/urgent] genirq: Properly pair kobject_del() with kobject_add()
Date: Mon, 19 Aug 2019 07:01:06 -0700	[thread overview]
Message-ID: <tip-e1ee29624746fbf667f80e8ae3815a76e4d1bd5b@git.kernel.org> (raw)
In-Reply-To: <1564703564-4116-1-git-send-email-mikelley@microsoft.com>

Commit-ID:  e1ee29624746fbf667f80e8ae3815a76e4d1bd5b
Gitweb:     https://git.kernel.org/tip/e1ee29624746fbf667f80e8ae3815a76e4d1bd5b
Author:     Michael Kelley <mikelley@microsoft.com>
AuthorDate: Thu, 1 Aug 2019 23:53:53 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 Aug 2019 15:56:28 +0200

genirq: Properly pair kobject_del() with kobject_add()

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 ]

Fixes: ecb3f394c5db ("genirq: Expose interrupt information through sysfs")
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/1564703564-4116-1-git-send-email-mikelley@microsoft.com

---
 kernel/irq/irqdesc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 9484e88dabc2..51f42f3caf09 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -437,8 +437,14 @@ static void free_desc(unsigned int irq)
 	 *
 	 * The sysfs entry must be serialized against a concurrent
 	 * irq_sysfs_init() as well.
+	 *
+	 * 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.
 	 */
-	kobject_del(&desc->kobj);
+	if (irq_kobj_base)
+		kobject_del(&desc->kobj);
 	delete_irq_desc(irq);
 
 	/*

  parent reply	other threads:[~2019-08-19 14:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1564703564-4116-1-git-send-email-mikelley@microsoft.com>
2019-08-02  6:34 ` [PATCH 1/1] genirq: Properly pair kobject_del with kobject_add gregkh
     [not found]   ` <MWHPR21MB078463AB854A336842118405D7D90@MWHPR21MB0784.namprd21.prod.outlook.com>
2019-08-03  7:15     ` gregkh
2019-08-03  7:43       ` Thomas Gleixner
2019-08-19 14:01 ` tip-bot for Michael Kelley [this message]
     [not found]   ` <20190819212758.6D03D22CEC@mail.kernel.org>
2019-08-19 21:58     ` [tip:irq/urgent] genirq: Properly pair kobject_del() with kobject_add() Michael Kelley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-e1ee29624746fbf667f80e8ae3815a76e4d1bd5b@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).