dpaa2-console.c: free buffer before returning from dpaa2_console_read
authorRobert-Ionut Alexa <robert-ionut.alexa@nxp.com>
Fri, 23 Apr 2021 09:01:51 +0000 (12:01 +0300)
committerXiaobo Xie <xiaobo.xie@nxp.com>
Thu, 3 Jun 2021 04:09:09 +0000 (06:09 +0200)
Dpaa2_console_read function frees kbuf buffer before returning.
The variable no longer goes out of scope, leaking the storage it
points to.

Signed-off-by: Robert-Ionut Alexa <robert-ionut.alexa@nxp.com>
drivers/soc/fsl/dpaa2-console.c

index 27243f7..e823fb9 100644 (file)
@@ -3,7 +3,7 @@
  * Freescale DPAA2 Platforms Console Driver
  *
  * Copyright 2015-2016 Freescale Semiconductor Inc.
- * Copyright 2018 NXP
+ * Copyright 2021 NXP
  */
 
 #define pr_fmt(fmt) "dpaa2-console: " fmt
@@ -231,6 +231,7 @@ static ssize_t dpaa2_console_read(struct file *fp, char __user *buf,
        cd->cur_ptr += bytes;
        written += bytes;
 
+       kfree(kbuf);
        return written;
 
 err_free_buf: