soc: fsl: dpaa2-console: 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)
committerLi Yang <leoyang.li@nxp.com>
Thu, 21 Oct 2021 23:19:52 +0000 (18:19 -0500)
Free the kbuf buffer before returning from the dpaa2_console_read()
function. The variable no longer goes out of scope, leaking the storage
it points to.

Fixes: c93349d8c170 ("soc: fsl: add DPAA2 console support")
Signed-off-by: Robert-Ionut Alexa <robert-ionut.alexa@nxp.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
drivers/soc/fsl/dpaa2-console.c

index 27243f7..5391741 100644 (file)
@@ -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: