From: Olaf Kirch <okir@suse.de>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Prevent memory leak in devpts
Date: Wed, 25 Aug 2004 15:41:29 +0200 [thread overview]
Message-ID: <20040825134129.GJ24572@suse.de> (raw)
In-Reply-To: <20040825105252.GA24572@suse.de>
[-- Attachment #1: Type: text/plain, Size: 249 bytes --]
This is a lame self-followup. Kurt Garloff pointed out that I should
obviously handle the error case more gracefully than by oopsing.
Improved patch attached.
Olaf
--
Olaf Kirch | The Hardware Gods hate me.
okir@suse.de |
---------------+
[-- Attachment #2: devpts-dentry-refcount --]
[-- Type: text/plain, Size: 572 bytes --]
Index: linux-2.6.5/fs/devpts/inode.c
===================================================================
--- linux-2.6.5.orig/fs/devpts/inode.c
+++ linux-2.6.5/fs/devpts/inode.c
@@ -178,9 +178,13 @@ struct tty_struct *devpts_get_tty(int nu
{
struct dentry *dentry = get_node(number);
struct tty_struct *tty;
-
- tty = (IS_ERR(dentry) || !dentry->d_inode) ? NULL :
- dentry->d_inode->u.generic_ip;
+
+ tty = NULL;
+ if (!IS_ERR(dentry)) {
+ if (dentry->d_inode)
+ tty = dentry->d_inode->u.generic_ip;
+ dput(dentry);
+ }
up(&devpts_root->d_inode->i_sem);
prev parent reply other threads:[~2004-08-25 13:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-25 10:52 [PATCH] Prevent memory leak in devpts Olaf Kirch
2004-08-25 13:41 ` Olaf Kirch [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=20040825134129.GJ24572@suse.de \
--to=okir@suse.de \
--cc=akpm@osdl.org \
--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