From: Roberto Sassu <roberto.sassu@huawei.com> To: <airlied@linux.ie>, <kraxel@redhat.com>, <daniel@ffwll.ch> Cc: <dri-devel@lists.freedesktop.org>, <virtualization@lists.linux-foundation.org>, <linux-kernel@vger.kernel.org>, Roberto Sassu <roberto.sassu@huawei.com>, <stable@vger.kernel.org>, <syzbot+e9072e90624a31dfa85f@syzkaller.appspotmail.com> Subject: [PATCH] drm/virtio: Ensure that objs is not NULL in virtio_gpu_array_put_free() Date: Mon, 13 Dec 2021 19:31:22 +0100 [thread overview] Message-ID: <20211213183122.838119-1-roberto.sassu@huawei.com> (raw) If virtio_gpu_object_shmem_init() fails (e.g. due to fault injection, as it happened in the bug report by syzbot), virtio_gpu_array_put_free() could be called with objs equal to NULL. Ensure that objs is not NULL in virtio_gpu_array_put_free(), or otherwise return from the function. Cc: stable@vger.kernel.org # 5.13.x Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Reported-by: syzbot+e9072e90624a31dfa85f@syzkaller.appspotmail.com Fixes: 377f8331d0565 ("drm/virtio: fix possible leak/unlock virtio_gpu_object_array") --- drivers/gpu/drm/virtio/virtgpu_gem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c index 2de61b63ef91..48d3c9955f0d 100644 --- a/drivers/gpu/drm/virtio/virtgpu_gem.c +++ b/drivers/gpu/drm/virtio/virtgpu_gem.c @@ -248,6 +248,9 @@ void virtio_gpu_array_put_free(struct virtio_gpu_object_array *objs) { u32 i; + if (!objs) + return; + for (i = 0; i < objs->nents; i++) drm_gem_object_put(objs->objs[i]); virtio_gpu_array_free(objs); -- 2.32.0
WARNING: multiple messages have this Message-ID (diff)
From: Roberto Sassu <roberto.sassu@huawei.com> To: <airlied@linux.ie>, <kraxel@redhat.com>, <daniel@ffwll.ch> Cc: syzbot+e9072e90624a31dfa85f@syzkaller.appspotmail.com, Roberto Sassu <roberto.sassu@huawei.com>, linux-kernel@vger.kernel.org, stable@vger.kernel.org, virtualization@lists.linux-foundation.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/virtio: Ensure that objs is not NULL in virtio_gpu_array_put_free() Date: Mon, 13 Dec 2021 19:31:22 +0100 [thread overview] Message-ID: <20211213183122.838119-1-roberto.sassu@huawei.com> (raw) If virtio_gpu_object_shmem_init() fails (e.g. due to fault injection, as it happened in the bug report by syzbot), virtio_gpu_array_put_free() could be called with objs equal to NULL. Ensure that objs is not NULL in virtio_gpu_array_put_free(), or otherwise return from the function. Cc: stable@vger.kernel.org # 5.13.x Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Reported-by: syzbot+e9072e90624a31dfa85f@syzkaller.appspotmail.com Fixes: 377f8331d0565 ("drm/virtio: fix possible leak/unlock virtio_gpu_object_array") --- drivers/gpu/drm/virtio/virtgpu_gem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c index 2de61b63ef91..48d3c9955f0d 100644 --- a/drivers/gpu/drm/virtio/virtgpu_gem.c +++ b/drivers/gpu/drm/virtio/virtgpu_gem.c @@ -248,6 +248,9 @@ void virtio_gpu_array_put_free(struct virtio_gpu_object_array *objs) { u32 i; + if (!objs) + return; + for (i = 0; i < objs->nents; i++) drm_gem_object_put(objs->objs[i]); virtio_gpu_array_free(objs); -- 2.32.0
next reply other threads:[~2021-12-13 18:32 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-13 18:31 Roberto Sassu [this message] 2021-12-13 18:31 ` [PATCH] drm/virtio: Ensure that objs is not NULL in virtio_gpu_array_put_free() Roberto Sassu 2021-12-16 15:12 ` Roberto Sassu 2021-12-16 15:12 ` Roberto Sassu 2022-01-18 6:56 ` Gerd Hoffmann 2022-01-18 6:56 ` Gerd Hoffmann 2022-01-18 6:56 ` Gerd Hoffmann
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211213183122.838119-1-roberto.sassu@huawei.com \ --to=roberto.sassu@huawei.com \ --cc=airlied@linux.ie \ --cc=daniel@ffwll.ch \ --cc=dri-devel@lists.freedesktop.org \ --cc=kraxel@redhat.com \ --cc=linux-kernel@vger.kernel.org \ --cc=stable@vger.kernel.org \ --cc=syzbot+e9072e90624a31dfa85f@syzkaller.appspotmail.com \ --cc=virtualization@lists.linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.