misc: fastrpc: Fix an incomplete memory release in fastrpc_rpmsg_probe()

[ Upstream commit 0978de9fc7 ]

fastrpc_channel_ctx is not freed if misc_register() fails, this would
lead to a memory leak. Fix this leak by adding kfree in misc_register()
error path.

Fixes: 278d56f970 ("misc: fastrpc: Reference count channel context")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20200511162722.2552-1-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Srinivas Kandagatla 2020-05-11 17:27:22 +01:00 committed by Greg Kroah-Hartman
parent c2ff1fcc25
commit 8d8991bb2b
1 changed files with 3 additions and 1 deletions

View File

@ -1434,8 +1434,10 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
domains[domain_id]);
data->miscdev.fops = &fastrpc_fops;
err = misc_register(&data->miscdev);
if (err)
if (err) {
kfree(data);
return err;
}
kref_init(&data->refcount);