Commit 60f2e8f8a07331097a57ec4abcdc680405579377
Committed by
Chris Mason
1 parent
4baf8c9201
Exists in
master
and in
7 other branches
Btrfs: correct error-handling zlib error handling
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>
Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff
fs/btrfs/zlib.c
... | ... | @@ -208,7 +208,7 @@ |
208 | 208 | *total_in = 0; |
209 | 209 | |
210 | 210 | workspace = find_zlib_workspace(); |
211 | - if (!workspace) | |
211 | + if (IS_ERR(workspace)) | |
212 | 212 | return -1; |
213 | 213 | |
214 | 214 | if (Z_OK != zlib_deflateInit(&workspace->def_strm, 3)) { |
... | ... | @@ -366,7 +366,7 @@ |
366 | 366 | char *kaddr; |
367 | 367 | |
368 | 368 | workspace = find_zlib_workspace(); |
369 | - if (!workspace) | |
369 | + if (IS_ERR(workspace)) | |
370 | 370 | return -ENOMEM; |
371 | 371 | |
372 | 372 | data_in = kmap(pages_in[page_in_index]); |
... | ... | @@ -547,7 +547,7 @@ |
547 | 547 | return -ENOMEM; |
548 | 548 | |
549 | 549 | workspace = find_zlib_workspace(); |
550 | - if (!workspace) | |
550 | + if (IS_ERR(workspace)) | |
551 | 551 | return -ENOMEM; |
552 | 552 | |
553 | 553 | workspace->inf_strm.next_in = data_in; |