ndctl: fix ordering of closing vs invalidating flush_fd
Vishal Verma
maintainerPATCH 1/1 ndctl: fix ordering of closing vs invalidating flush_fd
Static analysis warns that we may be closing a negative 'fd'. Fix this by closing before invalidating the flush_fd with a -1 in add_region()
Fixes commit c64cc15 ("ndctl: add support in libndctl to provide deep flush")
Cc Dave Jiang <[email protected]>
Signed-off-by Vishal Verma <[email protected]>
--- ndctl/lib/libndctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ndctl/lib/libndctl.c +1 -1
@@ -1929,8 +1929,8 @@ static void *add_region(void *parent, int id, const char *region_base) perm =strtol (buf,NULL ,0 );if (perm ==0 ) { - region->flush_fd =-1 ;close (region->flush_fd); + region->flush_fd =-1 ; } out:
Signature · 6 lines
2.14.3 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 6 lines · Vishal Verma
Static analysis warns that we may be closing a negative 'fd'. Fix this by closing before invalidating the
flush_fdwith a -1 inadd_region()Fixes commit c64cc15 ("ndctl: add support in libndctl to provide deep flush")Cc Dave Jiang <[email protected]>Signed-off-by Vishal Verma <[email protected]>
Good catch!
Acked-by Dave Jiang <[email protected]>
Quoted 10 lines
--- ndctl/lib/libndctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)ndctl/lib/libndctl.c +0
-0
ndctl/lib/libndctl.c static void *add_region(void *parent, int id, const char *region_base) · line 1936
Quoted 9 lines
ndctl/lib/libndctl.c +1
-1@@ -1929,8 +1929,8 @@ static void *add_region(void *parent, int id, const char *region_base) perm =strtol (buf,NULL ,0 );if (perm ==0 ) { - region->flush_fd =-1 ;close (region->flush_fd); + region->flush_fd =-1 ; } out:
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm