From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [smatch stuff] xshm: release misc device on error
Date: Thu, 08 Dec 2011 19:24:41 +0000 [thread overview]
Message-ID: <20111208192441.GB8810@elgon.mountain> (raw)
Hi Sjur,
Smatch complains that we don't release the misc device on error.
drivers/xshm/xshm_chr.c +1057 cfshm_probe(75)
warn: '&dev->misc' was not released on error
1043 /* Register the device. */
1044 dev->misc.parent = &xshm->pdev.dev;
1045 result = misc_register(&dev->misc);
1046
1047 /* Lock in order to try to stop someone from opening the device
1048 * too early. The misc device has its own lock. We cannot take our
1049 * lock until misc_register() is finished, because in open() the
1050 * locks are taken in this order (misc first and then dev).
1051 * So anyone managing to open the device between the misc_register
1052 * and the mutex_lock will get a "device not found" error. Don't
1053 * think it can be avoided.
1054 */
1055 if (mutex_lock_interruptible(&dev->mutex)) {
1056 xdev_dbg(dev, "mutex_lock_interruptible got signalled\n");
-> if result is 0 here we should release it. Should we call
xshmchr_put() or misc_deregister()?
1057 return -ERESTARTSYS;
1058 }
1059
1060 if (result < 0) {
1061 pr_warn("XSHMCHR: chnl_chr: error - %d, can't register misc.\n",
1062 result);
1063 mutex_unlock(&dev->mutex);
1064 goto err_failed;
1065 }
regards,
dan carpenter
next reply other threads:[~2011-12-08 19:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-08 19:24 Dan Carpenter [this message]
2011-12-09 12:39 ` [smatch stuff] xshm: release misc device on error Sjur BRENDELAND
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=20111208192441.GB8810@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@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