Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60f2e8f8 authored by Julia Lawall's avatar Julia Lawall Committed by Chris Mason
Browse files

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: default avatarJulia Lawall <julia@diku.dk>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 4baf8c92
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -208,7 +208,7 @@ int btrfs_zlib_compress_pages(struct address_space *mapping,
	*total_in = 0;
	*total_in = 0;


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


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


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


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


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


	workspace->inf_strm.next_in = data_in;
	workspace->inf_strm.next_in = data_in;