Skip to content

Commit

Permalink
rpmsg: glink: Add check for kstrdup
Browse files Browse the repository at this point in the history
[ Upstream commit b5c9ee8 ]

Add check for the return value of kstrdup() and return the error
if it fails in order to avoid NULL pointer dereference.

Fixes: b4f8e52 ("rpmsg: Introduce Qualcomm RPM glink driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20230619030631.12361-1-jiasheng@iscas.ac.cn
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
JiangJias authored and gregkh committed Sep 13, 2023
1 parent f309ac8 commit cae0787
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/rpmsg/qcom_glink_native.c
Expand Up @@ -224,6 +224,10 @@ static struct glink_channel *qcom_glink_alloc_channel(struct qcom_glink *glink,

channel->glink = glink;
channel->name = kstrdup(name, GFP_KERNEL);
if (!channel->name) {
kfree(channel);
return ERR_PTR(-ENOMEM);
}

init_completion(&channel->open_req);
init_completion(&channel->open_ack);
Expand Down

0 comments on commit cae0787

Please sign in to comment.