i3c: master: fix a memory leak bug
authorWenwen Wang <wenwen@cs.uga.edu>
Sun, 11 Aug 2019 18:33:06 +0000 (13:33 -0500)
committerBoris Brezillon <boris.brezillon@collabora.com>
Mon, 12 Aug 2019 08:11:29 +0000 (10:11 +0200)
commit7afe9a4e56658bd659660ea10671831664469e5f
tree1ab408fe564e4392821a835135fa8ad69bd93650
parentb1ac3a4b9aa2f68d498824f1235788e67b51b486
i3c: master: fix a memory leak bug

In i3c_master_getmwl_locked(), the buffer used for the dest payload data is
allocated using kzalloc() in i3c_ccc_cmd_dest_init(). Later on, the length
of the dest payload data is checked against 'sizeof(*mwl)'. If they are not
equal, -EIO is returned to indicate the error. However, the allocated
buffer is not deallocated on this path, leading to a memory leak.

To fix the above issue, free the buffer before returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
drivers/i3c/master.c