From: Jason Hrycay <jason.hrycay@motorola.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] driver core: fix race between creating/querying glue dir and its cleanup
Date: Tue, 21 Jun 2016 15:46:16 +0000 (UTC) [thread overview]
Message-ID: <loom.20160621T174448-519@post.gmane.org> (raw)
In-Reply-To: <571FA500.2080500@codeaurora.org>
Hi Ming/Chandrasekhar,
Chandra Sekhar Lingutla <clingutla <at> codeaurora.org> writes:
>
> Hi Ming,
>
> [...]
> > +static inline bool live_in_glue_dir(struct kobject *kobj,
> > + struct device *dev)
> > +{
> > + if (!kobj || !dev->class ||
> > + kobj->kset != &dev->class->p->glue_dirs)
> > + return true;
> > + return false;
> > +}
> I think we should return false if kobj->kset != &dev->class->p->glue_dirs.
> If kboj->kset points to dev->class->p->glue_dirs, then we live in glue dir.
> So logic should be:
> if (!kobj || !dev->class ||
> kobj->kset != &dev->class->p->glue_dirs)
> return false;
> return true;
>
> > +
> > +static inline struct kobject *get_glue_dir(struct device *dev)
> > +{
> > + if (live_in_glue_dir(&dev->kobj, dev))
> > + return dev->kobj.parent;
> > + return NULL;
> > +}
I don't think we should be checking the live_in_glue_dir on dev->kobj above,
but rather, dev->kobj.parent. That being said, I don't think the check is
even needed as it's going to be re-checked in the cleanup_glue_dir.
The issue is, if we fail the 'live_in_glue_dir' check on the dev->kobj, we'll
return NULL and subsequently fail to kobject_put the dev->kobj.parent in the
cleanup_glue_dir function, leaking a reference.
> [snip]
Regards,
Jason Hrycay
jason.hrycay@motorola.com
prev parent reply other threads:[~2016-06-21 16:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-28 8:27 Ming Lei
2016-04-26 17:27 ` Chandra Sekhar Lingutla
2016-05-10 6:00 ` Chandra Sekhar Lingutla
2016-06-21 15:46 ` Jason Hrycay [this message]
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=loom.20160621T174448-519@post.gmane.org \
--to=jason.hrycay@motorola.com \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome