Hello Steven Rostedt (Google),

The patch 704f960dbee2: "eventfs: Read ei->entries before
ei->children in eventfs_iterate()" from Jan 4, 2024 (linux-next),
leads to the following Smatch static checker warning:

        fs/tracefs/event_inode.c:775 eventfs_iterate()
        warn: missing error code here? 'create_file_dentry()' failed. 'ret' = 
'0'

fs/tracefs/event_inode.c
    749         /*
    750          * Need to create the dentries and inodes to have a consistent
    751          * inode number.
    752          */
    753         ret = 0;

Should this assignment be inside the loop?

    754 
    755         /* Start at 'c' to jump over already read entries */
    756         for (i = c; i < ei->nr_entries; i++, ctx->pos++) {
    757                 void *cdata = ei->data;
    758 
    759                 entry = &ei->entries[i];
    760                 name = entry->name;
    761 
    762                 mutex_lock(&eventfs_mutex);
    763                 /* If ei->is_freed then just bail here, nothing more to 
do */
    764                 if (ei->is_freed) {
    765                         mutex_unlock(&eventfs_mutex);
    766                         goto out;

On the second iteration through the loop then ret is an error code

    767                 }
    768                 r = entry->callback(name, &mode, &cdata, &fops);
    769                 mutex_unlock(&eventfs_mutex);
    770                 if (r <= 0)
    771                         continue;

that comes from r = entry->callback().  Except, hm, none of the callback
currently return anything except zero or one so it's not an issue yet.

    772 
    773                 dentry = create_file_dentry(ei, i, ei_dentry, name, 
mode, cdata, fops);
    774                 if (!dentry)
--> 775                         goto out;
    776                 ino = dentry->d_inode->i_ino;
    777                 dput(dentry);
    778 
    779                 if (!dir_emit(ctx, name, strlen(name), ino, DT_REG))
    780                         goto out;
    781         }
    782 
    783         /* Subtract the skipped entries above */
    784         c -= min((unsigned int)c, (unsigned int)ei->nr_entries);
    785 

regards,
dan carpenter

Reply via email to