From patchwork Thu Jan 28 14:17:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 12053767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21447C433DB for ; Thu, 28 Jan 2021 14:17:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 72ABF64D9D for ; Thu, 28 Jan 2021 14:17:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72ABF64D9D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A64876B0006; Thu, 28 Jan 2021 09:17:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A144A6B006C; Thu, 28 Jan 2021 09:17:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DD286B0070; Thu, 28 Jan 2021 09:17:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 755FE6B0006 for ; Thu, 28 Jan 2021 09:17:42 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3A5781EF2 for ; Thu, 28 Jan 2021 14:17:42 +0000 (UTC) X-FDA: 77755387164.25.linen81_5f129fa275a0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 0B7F91804E3C5 for ; Thu, 28 Jan 2021 14:17:42 +0000 (UTC) X-HE-Tag: linen81_5f129fa275a0 X-Filterd-Recvd-Size: 2143 Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Jan 2021 14:17:41 +0000 (UTC) Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l586y-0001nf-Rd; Thu, 28 Jan 2021 14:17:28 +0000 From: Colin King To: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , Tian Tao , Stephen Rothwell , linux-mm@kvack.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] mm/zswap: fix potential uninitialized pointer read on tmp Date: Thu, 28 Jan 2021 14:17:28 +0000 Message-Id: <20210128141728.639030-1-colin.king@canonical.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Colin Ian King In the case where zpool_can_sleep_mapped(pool) returns 0 then tmp is not allocated and tmp is then an uninitialized pointer. Later if entry is null, tmp is freed, hence free'ing an uninitialized pointer. Fix this by ensuring tmp is initialized to NULL. Addresses-Coverity: ("Uninitialized pointer read") Fixes: 908aa806dba0 ("mm/zswap: fix potential memory leak") Signed-off-by: Colin Ian King --- mm/zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/zswap.c b/mm/zswap.c index 8d1381b1178d..578d9f256920 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -935,7 +935,7 @@ static int zswap_writeback_entry(struct zpool *pool, unsigned long handle) struct scatterlist input, output; struct crypto_acomp_ctx *acomp_ctx; - u8 *src, *tmp; + u8 *src, *tmp = NULL; unsigned int dlen; int ret; struct writeback_control wbc = {