Skip to content

Commit b5c9ee8

Browse files
JiangJiasandersson
authored andcommitted
rpmsg: glink: Add check for kstrdup
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>
1 parent 5550201 commit b5c9ee8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/rpmsg/qcom_glink_native.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ static struct glink_channel *qcom_glink_alloc_channel(struct qcom_glink *glink,
227227

228228
channel->glink = glink;
229229
channel->name = kstrdup(name, GFP_KERNEL);
230+
if (!channel->name) {
231+
kfree(channel);
232+
return ERR_PTR(-ENOMEM);
233+
}
230234

231235
init_completion(&channel->open_req);
232236
init_completion(&channel->open_ack);

0 commit comments

Comments
 (0)