]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdstat.c
sysfs: Avoid if and return on the same line
[thirdparty/mdadm.git] / mdstat.c
index 2972cdf63288495606db90908c3a5baa04950cca..39628967047e7b8275269871fdd79507fa5112e3 100644 (file)
--- a/mdstat.c
+++ b/mdstat.c
@@ -133,7 +133,11 @@ struct mdstat_ent *mdstat_read(int hold, int start)
        int fd;
 
        if (hold && mdstat_fd != -1) {
-               lseek(mdstat_fd, 0L, 0);
+               off_t offset = lseek(mdstat_fd, 0L, 0);
+               if (offset == (off_t)-1) {
+                       mdstat_close();
+                       return NULL;
+               }
                fd = dup(mdstat_fd);
                if (fd >= 0)
                        f = fdopen(fd, "r");