aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/sw
diff options
context:
space:
mode:
authorMartina Kollarova <[email protected]>2016-09-08 15:12:42 +0300
committerEmil Velikov <[email protected]>2016-09-14 14:36:43 +0100
commit2527e18eebe2faf395d1682db7df76043aca6ea3 (patch)
tree13c53ef4dfe8723df599d60fbac47a3dee6602c4 /src/gallium/winsys/sw
parentab29788250a705eb0dd517cb3d38f37f944eb8ad (diff)
gallium: fix return value check
A possible error (-1) was being lost because it was first converted to an unsigned int and only then checked. Reviewed-by: Nicolai Hähnle <[email protected]> Signed-off-by: Martina Kollarova <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/gallium/winsys/sw')
-rw-r--r--src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
index 07eca990d04..22e1c936ac5 100644
--- a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
@@ -252,18 +252,18 @@ kms_sw_displaytarget_add_from_prime(struct kms_sw_winsys *kms_sw, int fd,
if (!kms_sw_dt)
return NULL;
+ off_t lseek_ret = lseek(fd, 0, SEEK_END);
+ if (lseek_ret == -1) {
+ FREE(kms_sw_dt);
+ return NULL;
+ }
+ kms_sw_dt->size = lseek_ret;
kms_sw_dt->ref_count = 1;
kms_sw_dt->handle = handle;
- kms_sw_dt->size = lseek(fd, 0, SEEK_END);
kms_sw_dt->width = width;
kms_sw_dt->height = height;
kms_sw_dt->stride = stride;
- if (kms_sw_dt->size == (off_t)-1) {
- FREE(kms_sw_dt);
- return NULL;
- }
-
lseek(fd, 0, SEEK_SET);
list_add(&kms_sw_dt->link, &kms_sw->bo_list);