linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] tty: handle NULL parameters in free_tty_struct()
@ 2012-07-20  7:06 Dan Carpenter
  2012-07-20  9:48 ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2012-07-20  7:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, kernel-janitors

We sometimes pass NULL pointers to free_tty_struct().  One example where
it can happen is in the error handling code in pty_common_install().

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index ca7c25d..e49b839 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -181,6 +181,8 @@ struct tty_struct *alloc_tty_struct(void)
 
 void free_tty_struct(struct tty_struct *tty)
 {
+	if (!tty)
+		return;
 	if (tty->dev)
 		put_device(tty->dev);
 	kfree(tty->write_buf);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [patch] tty: handle NULL parameters in free_tty_struct()
  2012-07-20  7:06 [patch] tty: handle NULL parameters in free_tty_struct() Dan Carpenter
@ 2012-07-20  9:48 ` Alan Cox
  2012-07-20 21:32   ` Jiri Slaby
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2012-07-20  9:48 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors

On Fri, 20 Jul 2012 10:06:34 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> We sometimes pass NULL pointers to free_tty_struct().  One example where
> it can happen is in the error handling code in pty_common_install().
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Alan Cox <alan@linux.intel.com>

We probably shouldn't be passing NULLs there but making
free_tty_struct(NULL) a no-op matches the kfree and other behaviours and
is robust.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] tty: handle NULL parameters in free_tty_struct()
  2012-07-20  9:48 ` Alan Cox
@ 2012-07-20 21:32   ` Jiri Slaby
  0 siblings, 0 replies; 3+ messages in thread
From: Jiri Slaby @ 2012-07-20 21:32 UTC (permalink / raw)
  To: Alan Cox; +Cc: Dan Carpenter, Greg Kroah-Hartman, linux-kernel, kernel-janitors

On 07/20/2012 11:48 AM, Alan Cox wrote:
> On Fri, 20 Jul 2012 10:06:34 +0300
> Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
>> We sometimes pass NULL pointers to free_tty_struct().  One example where
>> it can happen is in the error handling code in pty_common_install().
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Acked-by: Alan Cox <alan@linux.intel.com>
> 
> We probably shouldn't be passing NULLs there but making
> free_tty_struct(NULL) a no-op matches the kfree and other behaviours and
> is robust.

Yes, this was unintended. Good catch, Dan.

thanks,
-- 
js
suse labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-20 21:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-20  7:06 [patch] tty: handle NULL parameters in free_tty_struct() Dan Carpenter
2012-07-20  9:48 ` Alan Cox
2012-07-20 21:32   ` Jiri Slaby

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).