qcacmn: Check NULL pointer before use it

Check NULL pointer before use it.

Change-Id: Id5b5d3ac38bffdbfee4463e93e3a586e9da1fac2
CRs-Fixed: 2177902
This commit is contained in:
Jiachao Wu 2018-01-24 17:48:22 +08:00 • committed by snandini
commit 69a4679e57

View file

@ -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;