fs/ntfs3: Add NTFS journal
Hello Konstantin Komarov,
Commit b46acd6a6a62 ("fs/ntfs3: Add NTFS journal") from Aug 13, 2021 (linux-next), leads to the following Smatch static checker warning:
fs/ntfs3/fslog.c:627 enum_rstbl() error: we previously assumed 't' could be null (see line 616)
fs/ntfs3/fslog.c
612 static inline void *enum_rstbl(struct RESTART_TABLE *t, void *c)
613 {
614 __le32 *e;
615 u32 bprt;
616 u16 rsize = t ? le16_to_cpu(t->size) : 0;
^If t is NULL this function will either return NULL or crash. Can t be NULL? If so, why not add a check for that at the beginning?
if (!t)
return NULL;
rsize = le16_to_cpu(t->size);
617
618 if (!c) {
619 if (!t || !t->total)
620 return NULL;
621 e = Add2Ptr(t, sizeof(struct RESTART_TABLE));
622 } else {
623 e = Add2Ptr(c, rsize);
624 }
625
626 /* Loop until we hit the first one allocated, or the end of the list. */
--> 627 for (bprt = bytes_per_rt(t); PtrOffset(t, e) < bprt;
^NULL dereference
628 e = Add2Ptr(e, rsize)) {
629 if (*e == RESTART_ENTRY_ALLOCATED_LE)
630 return e;
631 }
632 return NULL;
633 }regards,
dan carpenter