Skip to content

Commit

Permalink
Btrfs: correct error-handling zlib error handling
Browse files Browse the repository at this point in the history
find_zlib_workspace returns an ERR_PTR value in an error case instead of NULL.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@match exists@
expression x, E;
statement S1, S2;
@@

x = find_zlib_workspace(...)
... when != x = E
(
*  if (x == NULL || ...) S1 else S2
|
*  if (x == NULL && ...) S1 else S2
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Julia Lawall authored and Chris Mason committed Aug 7, 2009
1 parent 4baf8c9 commit 60f2e8f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/btrfs/zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ int btrfs_zlib_compress_pages(struct address_space *mapping,
*total_in = 0;

workspace = find_zlib_workspace();
if (!workspace)
if (IS_ERR(workspace))
return -1;

if (Z_OK != zlib_deflateInit(&workspace->def_strm, 3)) {
Expand Down Expand Up @@ -366,7 +366,7 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in,
char *kaddr;

workspace = find_zlib_workspace();
if (!workspace)
if (IS_ERR(workspace))
return -ENOMEM;

data_in = kmap(pages_in[page_in_index]);
Expand Down Expand Up @@ -547,7 +547,7 @@ int btrfs_zlib_decompress(unsigned char *data_in,
return -ENOMEM;

workspace = find_zlib_workspace();
if (!workspace)
if (IS_ERR(workspace))
return -ENOMEM;

workspace->inf_strm.next_in = data_in;
Expand Down

0 comments on commit 60f2e8f

Please sign in to comment.