mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomas Winkler <tomas.winkler@intel.com>
To: gregkh@linuxfoundation.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
	Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 1/8] mei: debugfs: validate dev is not null
Date: Mon, 21 Oct 2013 22:05:36 +0300	[thread overview]
Message-ID: <1382382343-12066-2-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1382382343-12066-1-git-send-email-tomas.winkler@intel.com>

make static analyzer happy and
validate dev argument before dereferencing

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/debugfs.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index e3870f2..9162491 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -30,11 +30,15 @@ static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf,
 	struct mei_device *dev = fp->private_data;
 	struct mei_me_client *cl;
 	const size_t bufsz = 1024;
-	char *buf = kzalloc(bufsz, GFP_KERNEL);
+	char *buf;
 	int i;
 	int pos = 0;
 	int ret;
 
+	if (!dev)
+		return -ENODEV;
+
+	buf = kzalloc(bufsz, GFP_KERNEL);
 	if  (!buf)
 		return -ENOMEM;
 
@@ -80,10 +84,14 @@ static ssize_t mei_dbgfs_read_devstate(struct file *fp, char __user *ubuf,
 {
 	struct mei_device *dev = fp->private_data;
 	const size_t bufsz = 1024;
-	char *buf = kzalloc(bufsz, GFP_KERNEL);
+	char *buf;
 	int pos = 0;
 	int ret;
 
+	if (!dev)
+		return -ENODEV;
+
+	buf = kzalloc(bufsz, GFP_KERNEL);
 	if  (!buf)
 		return -ENOMEM;
 
-- 
1.8.3.1


  reply	other threads:[~2013-10-21 19:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-21 19:05 [char-misc-next 0/8] mei security fixes and cleanups Tomas Winkler
2013-10-21 19:05 ` Tomas Winkler [this message]
2013-10-29 23:18   ` [char-misc-next 1/8] mei: debugfs: validate dev is not null Greg KH
2013-10-30  7:16     ` Winkler, Tomas
2013-10-30 13:26       ` Greg KH
2013-10-30 21:14         ` Winkler, Tomas
2013-10-21 19:05 ` [char-misc-next 2/8] mei: hbm: validate client index is not exceeding allocated array size Tomas Winkler
2013-10-29 23:19   ` Greg KH
2013-10-30  7:31     ` Winkler, Tomas
2013-10-30 13:27       ` Greg KH
2013-11-07 12:21         ` Winkler, Tomas
2013-10-21 19:05 ` [char-misc-next 3/8] mei: nfc: fix memory leak in error path Tomas Winkler
2013-10-21 19:05 ` [char-misc-next 4/8] mei: wd: host_init propagate error codes from called functions Tomas Winkler
2013-10-21 19:05 ` [char-misc-next 5/8] mei: bus: propagate error code returned by mei_me_cl_by_id Tomas Winkler
2013-10-21 19:05 ` [char-misc-next 6/8] mei: mei_cl_link remove duplicated check for open_handle_count Tomas Winkler
2013-10-21 19:05 ` [char-misc-next 7/8] mei: replace stray pr_debug with dev_dbg Tomas Winkler
2013-10-21 19:05 ` [char-misc-next 8/8] mei: print correct device state during unexpected reset Tomas Winkler

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=1382382343-12066-2-git-send-email-tomas.winkler@intel.com \
    --to=tomas.winkler@intel.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.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

all inboxes | Powered by JetHome®