Message ID | 20221212091117.43511-1-jiasheng@iscas.ac.cn (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/msm/gem: Add check for kmalloc | expand |
On 12/12/2022 11:11, Jiasheng Jiang wrote: > Add the check for the return value of kmalloc in order to avoid > NULL pointer dereference in copy_from_user. > > Fixes: 20224d715a88 ("drm/msm/submit: Move copy_from_user ahead of locking bos") > Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> > --- > drivers/gpu/drm/msm/msm_gem_submit.c | 4 ++++ > 1 file changed, 4 insertions(+) Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
On Mon, 12 Dec 2022 17:11:17 +0800, Jiasheng Jiang wrote: > Add the check for the return value of kmalloc in order to avoid > NULL pointer dereference in copy_from_user. > > Applied, thanks! [1/1] drm/msm/gem: Add check for kmalloc https://gitlab.freedesktop.org/lumag/msm/-/commit/d839f0811a31 Best regards,
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 45a3e5cadc7d..7c2cc1262c05 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -209,6 +209,10 @@ static int submit_lookup_cmds(struct msm_gem_submit *submit, goto out; } submit->cmd[i].relocs = kmalloc(sz, GFP_KERNEL); + if (!submit->cmd[i].relocs) { + ret = -ENOMEM; + goto out; + } ret = copy_from_user(submit->cmd[i].relocs, userptr, sz); if (ret) { ret = -EFAULT;
Add the check for the return value of kmalloc in order to avoid NULL pointer dereference in copy_from_user. Fixes: 20224d715a88 ("drm/msm/submit: Move copy_from_user ahead of locking bos") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> --- drivers/gpu/drm/msm/msm_gem_submit.c | 4 ++++ 1 file changed, 4 insertions(+)