Message ID | 813550c84636f7d570c541c22eee60b11346b4f3.1419005022.git.dsterba@suse.cz (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On 12/19/14 10:06 AM, David Sterba wrote: > If the tree's empty, we'll get NULL and dereference it. Hm, but this is under an explicit check for not empty: while (!cache_tree_empty(roots_info_cache)) { sooo? Maybe it's just defensive? Nothing really wrong with being defensive, I suppose, so: Reviewed-by: Eric Sandeen <sandeen@redhat.com> > Resolves-Coverity-CID: 1248828 > Signed-off-by: David Sterba <dsterba@suse.cz> > --- > cmds-check.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/cmds-check.c b/cmds-check.c > index 6eea36c2f52c..3e7a4ebdce44 100644 > --- a/cmds-check.c > +++ b/cmds-check.c > @@ -8075,6 +8075,8 @@ static void free_roots_info_cache(void) > struct root_item_info *rii; > > entry = first_cache_extent(roots_info_cache); > + if (!entry) > + break; > remove_cache_extent(roots_info_cache, entry); > rii = container_of(entry, struct root_item_info, cache_extent); > free(rii); > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Dec 19, 2014 at 10:56:41AM -0600, Eric Sandeen wrote: > On 12/19/14 10:06 AM, David Sterba wrote: > > If the tree's empty, we'll get NULL and dereference it. > > Hm, but this is under an explicit check for not empty: > > while (!cache_tree_empty(roots_info_cache)) { > > sooo? Maybe it's just defensive? Nothing really wrong > with being defensive, I suppose, so: Well, mostly to shut up the warning with a minimal change. It could be rewritten to while ((entry = ...)) { ... } as in other places. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/cmds-check.c b/cmds-check.c index 6eea36c2f52c..3e7a4ebdce44 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -8075,6 +8075,8 @@ static void free_roots_info_cache(void) struct root_item_info *rii; entry = first_cache_extent(roots_info_cache); + if (!entry) + break; remove_cache_extent(roots_info_cache, entry); rii = container_of(entry, struct root_item_info, cache_extent); free(rii);
If the tree's empty, we'll get NULL and dereference it. Resolves-Coverity-CID: 1248828 Signed-off-by: David Sterba <dsterba@suse.cz> --- cmds-check.c | 2 ++ 1 file changed, 2 insertions(+)