drm/nouveau: fix handling empty channel list in ioctl's
If there are no channels, chan would never end up being NULL, and so the null pointer check would fail. Solve this by initializing chan to NULL, and iterating over temp instead. Fixes oops when running intel-gpu-tools/tests/kms_flip, which attempts to do some intel ioctl's on a nouveau device. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Cc: stable@vger.kernel.org [3.7+] Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
This commit is contained in:
Родитель
f60b6e7a60
Коммит
b43decd2c5
|
@ -391,7 +391,7 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
|
||||||
struct nouveau_drm *drm = nouveau_drm(dev);
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
||||||
struct nouveau_device *device = nv_device(drm->device);
|
struct nouveau_device *device = nv_device(drm->device);
|
||||||
struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
|
struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
|
||||||
struct nouveau_abi16_chan *chan, *temp;
|
struct nouveau_abi16_chan *chan = NULL, *temp;
|
||||||
struct nouveau_abi16_ntfy *ntfy;
|
struct nouveau_abi16_ntfy *ntfy;
|
||||||
struct nouveau_object *object;
|
struct nouveau_object *object;
|
||||||
struct nv_dma_class args = {};
|
struct nv_dma_class args = {};
|
||||||
|
@ -404,10 +404,11 @@ nouveau_abi16_ioctl_notifierobj_alloc(ABI16_IOCTL_ARGS)
|
||||||
if (unlikely(nv_device(abi16->device)->card_type >= NV_C0))
|
if (unlikely(nv_device(abi16->device)->card_type >= NV_C0))
|
||||||
return nouveau_abi16_put(abi16, -EINVAL);
|
return nouveau_abi16_put(abi16, -EINVAL);
|
||||||
|
|
||||||
list_for_each_entry_safe(chan, temp, &abi16->channels, head) {
|
list_for_each_entry(temp, &abi16->channels, head) {
|
||||||
if (chan->chan->handle == (NVDRM_CHAN | info->channel))
|
if (temp->chan->handle == (NVDRM_CHAN | info->channel)) {
|
||||||
|
chan = temp;
|
||||||
break;
|
break;
|
||||||
chan = NULL;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chan)
|
if (!chan)
|
||||||
|
@ -459,17 +460,18 @@ nouveau_abi16_ioctl_gpuobj_free(ABI16_IOCTL_ARGS)
|
||||||
{
|
{
|
||||||
struct drm_nouveau_gpuobj_free *fini = data;
|
struct drm_nouveau_gpuobj_free *fini = data;
|
||||||
struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
|
struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv, dev);
|
||||||
struct nouveau_abi16_chan *chan, *temp;
|
struct nouveau_abi16_chan *chan = NULL, *temp;
|
||||||
struct nouveau_abi16_ntfy *ntfy;
|
struct nouveau_abi16_ntfy *ntfy;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (unlikely(!abi16))
|
if (unlikely(!abi16))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
list_for_each_entry_safe(chan, temp, &abi16->channels, head) {
|
list_for_each_entry(temp, &abi16->channels, head) {
|
||||||
if (chan->chan->handle == (NVDRM_CHAN | fini->channel))
|
if (temp->chan->handle == (NVDRM_CHAN | fini->channel)) {
|
||||||
|
chan = temp;
|
||||||
break;
|
break;
|
||||||
chan = NULL;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chan)
|
if (!chan)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче