diff options
author | Colin Ian King <colin.king@canonical.com> | 2017-09-08 10:13:33 -0400 |
---|---|---|
committer | Oded Gabbay <oded.gabbay@gmail.com> | 2017-09-08 10:13:33 -0400 |
commit | bfaa1ce809bbcd12b1399409ab1dbf0cdaba6e27 (patch) | |
tree | d9756188eedec6d415652f8d7cad20d229f61dc0 | |
parent | 56eac98b8a0bbb72132340dbfedc912c68c4bd56 (diff) |
drm/amdkfd: check for null dev to avoid a null pointer dereference
The call to kfd_device_by_id can potentially return null, so check that
dev is null and return with -EINVAL to avoid a null pointer dereference.
Detected by CoverityScan CID#1454629 ("Dereference null return value")
Fixes: 5d71dbc3a588 ("drm/amdkfd: Implement image tiling mode support v2")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index e4a8c2e52cb2..660b3fbade41 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | |||
@@ -892,6 +892,8 @@ static int kfd_ioctl_get_tile_config(struct file *filep, | |||
892 | int err = 0; | 892 | int err = 0; |
893 | 893 | ||
894 | dev = kfd_device_by_id(args->gpu_id); | 894 | dev = kfd_device_by_id(args->gpu_id); |
895 | if (!dev) | ||
896 | return -EINVAL; | ||
895 | 897 | ||
896 | dev->kfd2kgd->get_tile_config(dev->kgd, &config); | 898 | dev->kfd2kgd->get_tile_config(dev->kgd, &config); |
897 | 899 | ||