Browse Source

qcacmn: Check NULL pointer before use it

Check NULL pointer before use it.

Change-Id: Id5b5d3ac38bffdbfee4463e93e3a586e9da1fac2
CRs-Fixed: 2177902
Jiachao Wu 7 years ago
parent
commit
69a4679e57
1 changed files with 7 additions and 5 deletions
  1. 7 5
      qdf/linux/src/qdf_debugfs.c

+ 7 - 5
qdf/linux/src/qdf_debugfs.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -254,10 +254,12 @@ static ssize_t qdf_seq_write(struct file *filp, const char __user *ubuf,
 	fops = seq->private;
 	if (fops && fops->write) {
 		buf = qdf_mem_malloc(len + 1);
-		buf[len] = '\0';
-		rc = simple_write_to_buffer(buf, len, ppos, ubuf, len);
-		fops->write(fops->priv, buf, len + 1);
-		qdf_mem_free(buf);
+		if (buf) {
+			buf[len] = '\0';
+			rc = simple_write_to_buffer(buf, len, ppos, ubuf, len);
+			fops->write(fops->priv, buf, len + 1);
+			qdf_mem_free(buf);
+		}
 	}
 
 	return rc;