提交 cc8422e2 编写于 作者: C Christophe JAILLET 提交者: Zheng Zengkai

dmaengine: idxd: Fix the error handling path in idxd_cdev_register()

stable inclusion
from stable-v5.10.121
commit 6073af78156b8c3fc1198f8bcc190b7ac3ac0143
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6073af78156b8c3fc1198f8bcc190b7ac3ac0143

--------------------------------

[ Upstream commit aab08c1a ]

If a call to alloc_chrdev_region() fails, the already allocated resources
are leaking.

Add the needed error handling path to fix the leak.

Fixes: 42d279f9 ("dmaengine: idxd: add char driver to expose submission portal to userland")
Signed-off-by: NChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: NDave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/1b5033dcc87b5f2a953c413f0306e883e6114542.1650521591.git.christophe.jaillet@wanadoo.frSigned-off-by: NVinod Koul <vkoul@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 150ca145
...@@ -266,10 +266,16 @@ int idxd_cdev_register(void) ...@@ -266,10 +266,16 @@ int idxd_cdev_register(void)
rc = alloc_chrdev_region(&ictx[i].devt, 0, MINORMASK, rc = alloc_chrdev_region(&ictx[i].devt, 0, MINORMASK,
ictx[i].name); ictx[i].name);
if (rc) if (rc)
return rc; goto err_free_chrdev_region;
} }
return 0; return 0;
err_free_chrdev_region:
for (i--; i >= 0; i--)
unregister_chrdev_region(ictx[i].devt, MINORMASK);
return rc;
} }
void idxd_cdev_remove(void) void idxd_cdev_remove(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册