From 69a4679e57716fe09e12ee839096647f33896704 Mon Sep 17 00:00:00 2001 From: Jiachao Wu Date: Wed, 24 Jan 2018 17:48:22 +0800 Subject: [PATCH] qcacmn: Check NULL pointer before use it Check NULL pointer before use it. Change-Id: Id5b5d3ac38bffdbfee4463e93e3a586e9da1fac2 CRs-Fixed: 2177902 --- qdf/linux/src/qdf_debugfs.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qdf/linux/src/qdf_debugfs.c b/qdf/linux/src/qdf_debugfs.c index 24e21c71f8e7..11b1432a704c 100644 --- a/qdf/linux/src/qdf_debugfs.c +++ b/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;