]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rpmsg: glink: Add check for kstrdup
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Mon, 19 Jun 2023 03:06:31 +0000 (11:06 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 08:46:59 +0000 (10:46 +0200)
[ Upstream commit b5c9ee8296a3760760c7b5d2e305f91412adc795 ]

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

Fixes: b4f8e52b89f6 ("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>
drivers/rpmsg/qcom_glink_native.c

index 0fb185e0620aa999f14c5f5fc2e8ae7df3e26d98..c1dfad2986859c548dcaa61bb3f5bf55fd1e8f61 100644 (file)
@@ -225,6 +225,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);