diff options
author | Jiasheng Jiang | 2023-06-19 11:06:31 +0800 |
---|---|---|
committer | Greg Kroah-Hartman | 2023-09-13 09:42:58 +0200 |
commit | cae0787e408c30a575760a531ccb69a6b48bbfaf (patch) | |
tree | fba558eedf5bccbf87fc896979946380eafaed6d | |
parent | f309ac8a4db92ba68109fa025a0ea9b3c8430597 (diff) |
rpmsg: glink: Add check for kstrdup
[ 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>
-rw-r--r-- | drivers/rpmsg/qcom_glink_native.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 67e7664efb0d..cb8f65c1d4e3 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -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); |