From: Kulikov Vasiliy <segooon@gmail.com>
To: kernel-janitors@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
Mauro Carvalho Chehab <mchehab@redhat.com>,
Stefan Ringel <stefan.ringel@arcor.de>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH 08/15] staging: tm6000: fix null dereference and memory leak
Date: Fri, 16 Jul 2010 20:14:49 +0400 [thread overview]
Message-ID: <1279296889-25063-1-git-send-email-segooon@gmail.com> (raw)
Do not dereference ir_input_dev if it is NULL.
Also free ir_input_dev->input_dev on error path.
Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
---
drivers/staging/tm6000/tm6000-input.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/tm6000/tm6000-input.c b/drivers/staging/tm6000/tm6000-input.c
index 32f7a0a..5edf728 100644
--- a/drivers/staging/tm6000/tm6000-input.c
+++ b/drivers/staging/tm6000/tm6000-input.c
@@ -247,8 +247,10 @@ int tm6000_ir_init(struct tm6000_core *dev)
ir = kzalloc(sizeof(*ir), GFP_KERNEL);
ir_input_dev = kzalloc(sizeof(*ir_input_dev), GFP_KERNEL);
+ if (!ir || !ir_input_dev)
+ goto err_out_free;
ir_input_dev->input_dev = input_allocate_device();
- if (!ir || !ir_input_dev || !ir_input_dev->input_dev)
+ if (!ir_input_dev->input_dev)
goto err_out_free;
/* record handles to ourself */
@@ -330,6 +332,8 @@ int tm6000_ir_init(struct tm6000_core *dev)
err_out_stop:
dev->ir = NULL;
err_out_free:
+ if (ir_input_dev)
+ input_free_device(ir_input_dev->input_dev);
kfree(ir_input_dev);
kfree(ir);
return err;
--
1.7.0.4
reply other threads:[~2010-07-16 16:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1279296889-25063-1-git-send-email-segooon@gmail.com \
--to=segooon@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=stefan.ringel@arcor.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
all inboxes | Powered by JetHome®