Re: [PATCH libdrm 3/3] xf86drm: replace stat() with access() to verify file existence

2018-03-26 Thread Emil Velikov
On 26 March 2018 at 11:26, Eric Engestrom  wrote:
> Signed-off-by: Eric Engestrom 
> ---
>  xf86drm.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/xf86drm.c b/xf86drm.c
> index 5701952ae83634b47628..47a82407df82d37a59b2 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -3767,10 +3767,8 @@ int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr 
> *device)
>  return -EINVAL;
>
>  n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
> -if (n == -1 || n >= PATH_MAX)
> +if (n == -1 || n >= PATH_MAX || access(node, F_OK))
>return -errno;
> -if (stat(node, ))
> -return -EINVAL;
>
Above all - there's a beefy RATIONALE section in man 3p access and I'm
wondering if 2) isn't applicable in some odd corner case.
If things are safe - please a) document why - perf./other reasons and
b) update the other instances.

-Emil
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH libdrm 3/3] xf86drm: replace stat() with access() to verify file existence

2018-03-26 Thread Eric Engestrom
Signed-off-by: Eric Engestrom 
---
 xf86drm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/xf86drm.c b/xf86drm.c
index 5701952ae83634b47628..47a82407df82d37a59b2 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3767,10 +3767,8 @@ int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr 
*device)
 return -EINVAL;
 
 n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
-if (n == -1 || n >= PATH_MAX)
+if (n == -1 || n >= PATH_MAX || access(node, F_OK))
   return -errno;
-if (stat(node, ))
-return -EINVAL;
 
 subsystem_type = drmParseSubsystemType(maj, min);
 if (subsystem_type != DRM_BUS_PCI)
-- 
Cheers,
  Eric

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel