From patchwork Fri Mar 31 19:32:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 9657237 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CF8D260350 for ; Fri, 31 Mar 2017 19:33:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1F2C286F7 for ; Fri, 31 Mar 2017 19:33:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6BE6286FB; Fri, 31 Mar 2017 19:33:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6392D286F7 for ; Fri, 31 Mar 2017 19:33:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3CCAA2E240B; Fri, 31 Mar 2017 19:33:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3CCAA2E240B Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3CCAA2E240B Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="YnLleYRk" Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 077F517CD6; Fri, 31 Mar 2017 19:33:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2C91618523C6; Fri, 31 Mar 2017 19:33:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2VJXAuV006544 for ; Fri, 31 Mar 2017 15:33:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id B632F17CD6; Fri, 31 Mar 2017 19:33:10 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEE904FA23 for ; Fri, 31 Mar 2017 19:33:06 +0000 (UTC) Received: from mail-pg0-f49.google.com (mail-pg0-f49.google.com [74.125.83.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A51EC8F95 for ; Fri, 31 Mar 2017 19:33:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0A51EC8F95 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=samitolvanen@google.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0A51EC8F95 Received: by mail-pg0-f49.google.com with SMTP id 21so79913660pgg.1 for ; Fri, 31 Mar 2017 12:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xxGYRzdcFSmrO42Ww348YgvwAorONYKIVPmZyYRTbjg=; b=YnLleYRkTKXGjMY6v+2qQwI6GutjUSQU+/lwazSoY/cK4f7o22ZIEaJxBp9Kn22U6N AoOgwmKymeaji086Prmj84t/ZkNxhadbSfhH4OJDKL/JBquwYgCL42ie2E0e6sM4TX2c /wbhrPtOVsEZiH6j/P7ERFjfpdbtE9MDVdF/4/cD++Vit7YNbKNsoCxk6uMZ2mYYi1ed 66s1Bo9hiw9w+5QpADpuC6FKdsq9Z0iw77fXZR1QH5l+FWFyUJ/3RJYfCODUyeujvl5/ vwqWt3iTQ0bBg3z7y1gEZC0pNfo8RFLQjU9fDc/lGFZlxZn1Ur31i+93e3idZkV8dpo0 Qefw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xxGYRzdcFSmrO42Ww348YgvwAorONYKIVPmZyYRTbjg=; b=rdbN5nsoDbH09ymmpzBXhnbZUQZH8iIbQdVaU1ugnx2TaNTTLVZh3Ye7CALkzcQbmR ObOCWF+v8BGpntzCFQJhoLsaq+yeUbP/5x3FeGJVu9ctb66HN5djRJ5h0ih1IL0yvoNw tnrQIzYV75BQWucyZ0ubc/2tJIM/9Q3308TBCELLibOSMmcS8AwONSaeG8RMXOMdEc92 eyZu6MfrMVpDl7I6UoDQj/npisUJmiEdNsPNPY3y3W0xcAHTcDETIenyZ0ZDD7kTy/l2 zsuyRCn6Krt6e0TZhJ4n/FI5l8zAnPdjSmWRlTU+HRwU2xIaQLx18ArnR7JvufTw9wDh 05Yg== X-Gm-Message-State: AFeK/H0szmurA5n77kiBjahdw+hX6tS9TNmppmAgQAGD8STUwO3YR5q9j9WxmKO9GAOUsZ8L X-Received: by 10.84.241.71 with SMTP id u7mr5039427plm.104.1490988785352; Fri, 31 Mar 2017 12:33:05 -0700 (PDT) Received: from samitolvanen.mtv.corp.google.com ([100.98.112.14]) by smtp.gmail.com with ESMTPSA id r8sm12043072pfk.80.2017.03.31.12.33.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 12:33:04 -0700 (PDT) From: Sami Tolvanen To: Mike Snitzer , dm-devel@redhat.com, michal virgovic , Milan Broz Date: Fri, 31 Mar 2017 12:32:45 -0700 Message-Id: <20170331193245.46999-2-samitolvanen@google.com> In-Reply-To: <20170331193245.46999-1-samitolvanen@google.com> References: <20170331193245.46999-1-samitolvanen@google.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 31 Mar 2017 19:33:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 31 Mar 2017 19:33:06 +0000 (UTC) for IP:'74.125.83.49' DOMAIN:'mail-pg0-f49.google.com' HELO:'mail-pg0-f49.google.com' FROM:'samitolvanen@google.com' RCPT:'' X-RedHat-Spam-Score: 0.768 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, RP_MATCHES_RCVD, SPF_PASS) 74.125.83.49 mail-pg0-f49.google.com 74.125.83.49 mail-pg0-f49.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: Sami Tolvanen Subject: [dm-devel] [PATCH 2/2] dm verity fec: fix bufio leaks X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 31 Mar 2017 19:33:17 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Buffers read through dm_bufio_read are not released in all code paths. Fixes: a739ff3f543a ("dm verity: add support for forward error correction") Signed-off-by: Sami Tolvanen --- drivers/md/dm-verity-fec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c index c3cc04d89524..78f36012eaca 100644 --- a/drivers/md/dm-verity-fec.c +++ b/drivers/md/dm-verity-fec.c @@ -146,8 +146,6 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio, block = fec_buffer_rs_block(v, fio, n, i); res = fec_decode_rs8(v, fio, block, &par[offset], neras); if (res < 0) { - dm_bufio_release(buf); - r = res; goto error; } @@ -172,6 +170,8 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio, done: r = corrected; error: + dm_bufio_release(buf); + if (r < 0 && neras) DMERR_LIMIT("%s: FEC %llu: failed to correct: %d", v->data_dev->name, (unsigned long long)rsb, r); @@ -269,7 +269,7 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io, &is_zero) == 0) { /* skip known zero blocks entirely */ if (is_zero) - continue; + goto done; /* * skip if we have already found the theoretical