From mboxrd@z Thu Jan 1 00:00:00 1970 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=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 1DDD9C433DF for ; Tue, 23 Jun 2020 14:02:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0D9420720 for ; Tue, 23 Jun 2020 14:02:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=konsulko.com header.i=@konsulko.com header.b="JvX0MDxx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732740AbgFWOCo (ORCPT ); Tue, 23 Jun 2020 10:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729504AbgFWOCn (ORCPT ); Tue, 23 Jun 2020 10:02:43 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DD29C061573 for ; Tue, 23 Jun 2020 07:02:43 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id n23so23532428ljh.7 for ; Tue, 23 Jun 2020 07:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+mDKHqL9XaZmj7XcsJJwYzkkEK6i2Pe8R8fplxjQ0ik=; b=JvX0MDxxQ7q45iyUquGhnRAfIa6C8NJAargxgnJLVJ1QKDLMHSQdE4DHqkXQDQQvMA 0BlItz+1HrqAU843jnYC7PfhRIxKT0JH19lnfBaqxGSiKEfVwkV0H5AeiwaryqbwipQ+ n5g+jwL4+9Joj4DgkA5NywYvIjzDIitw+83lU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+mDKHqL9XaZmj7XcsJJwYzkkEK6i2Pe8R8fplxjQ0ik=; b=MJiLpnTdMgao0ZcMbKkFBvNBRe2O2UopOd0hUyjqNAQu/ZhDJTntTx5mn5SLLgee10 rDCVdotZ/F+Am95wcerNkl0PUOkAA0ncq2Dog4uf2N04PnGrbnRde9dKqckNYpoiXvmr Bbp3AgyTHPCx2q1yGGKR+qrMcTn7GBS8+uDz4rL4DTA+gCLRJH/ssX4fjLPvPJ/luKhZ cJ+wpWszA64LyIKfxu85sce5oxc8ST40Kin72GtgqWVJvABJoCPRS6jXgOjny3drF8BB KG7dSbolIHksXHiGCZLB3shr3paxV1QPlj3V6QADwkBGXaT4WH+ig4B7RGiQ8JPThtRm FS2g== X-Gm-Message-State: AOAM533lsU/vngCDzwJKSkhVMHj3kGtBHGzNQRcYvUFh29QL7lPa18ZT B5tXWQIpIfaZHeO0Zt57XTlKJVIS0hH3H5IgCarsmggd5Bs= X-Google-Smtp-Source: ABdhPJwkp7xO233qrwVR3p5tSB1yZTt9QFCbp0qjfLwtRcyVzpREtRGELz74ul+4qEqtniyRgrWITwvGeGjIWMKuSHU= X-Received: by 2002:a2e:3603:: with SMTP id d3mr10508629lja.259.1592920961167; Tue, 23 Jun 2020 07:02:41 -0700 (PDT) MIME-Version: 1.0 References: <20200622153546.49880-1-colin.king@canonical.com> <20200622182816.GF4151@kadam> In-Reply-To: From: Vitaly Wool Date: Tue, 23 Jun 2020 16:02:29 +0200 Message-ID: Subject: Re: [PATCH][next] mm/zswap: fix a couple of memory leaks and rework kzalloc failure check To: Colin Ian King Cc: "Song Bao Hua (Barry Song)" , Dan Carpenter , Seth Jennings , Dan Streetman , Andrew Morton , Stephen Rothwell , "linux-mm@kvack.org" , "kernel-janitors@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 23, 2020, 1:12 PM Colin Ian King wrote: > > On 22/06/2020 20:55, Song Bao Hua (Barry Song) wrote: > > > > > >> -----Original Message----- > >> From: Dan Carpenter [mailto:dan.carpenter@oracle.com] > >> Sent: Tuesday, June 23, 2020 6:28 AM > >> To: Colin King > >> Cc: Seth Jennings ; Dan Streetman > >> ; Vitaly Wool ; Andrew > >> Morton ; Song Bao Hua (Barry Song) > >> ; Stephen Rothwell ; > >> linux-mm@kvack.org; kernel-janitors@vger.kernel.org; > >> linux-kernel@vger.kernel.org > >> Subject: Re: [PATCH][next] mm/zswap: fix a couple of memory leaks and > >> rework kzalloc failure check > >> > >> On Mon, Jun 22, 2020 at 04:35:46PM +0100, Colin King wrote: > >>> From: Colin Ian King > >>> > >>> kzalloc failures return NULL on out of memory errors, so replace the > >>> IS_ERR_OR_NULL check with the usual null pointer check. Fix two memory > >>> leaks with on acomp and acomp_ctx by ensuring these objects are free'd > >>> on the error return path. > >>> > >>> Addresses-Coverity: ("Resource leak") > >>> Fixes: d4f86abd6e35 ("mm/zswap: move to use crypto_acomp API for > >> hardware acceleration") > >>> Signed-off-by: Colin Ian King > > > > > > Colin, thanks for your patch. I am sorry I did the same thing with you here: > > https://lkml.org/lkml/2020/6/22/347 > > Thanks for fixing this correctly, I ran out of time yesterday to re-do > the fix. > > Colin I think this has gotten out of hand. Barry, could you please come up with a replacement for the initial patch rather than doing it incrementally? Thanks, Vitaly > > > > > > >>> --- > >>> mm/zswap.c | 16 +++++++++++----- > >>> 1 file changed, 11 insertions(+), 5 deletions(-) > >>> > >>> diff --git a/mm/zswap.c b/mm/zswap.c > >>> index 0d914ba6b4a0..14839cbac7ff 100644 > >>> --- a/mm/zswap.c > >>> +++ b/mm/zswap.c > >>> @@ -433,23 +433,23 @@ static int zswap_cpu_comp_prepare(unsigned int > >> cpu, struct hlist_node *node) > >>> return 0; > >>> > >>> acomp_ctx = kzalloc(sizeof(*acomp_ctx), GFP_KERNEL); > >>> - if (IS_ERR_OR_NULL(acomp_ctx)) { > >>> + if (!acomp_ctx) { > >>> pr_err("Could not initialize acomp_ctx\n"); > >>> return -ENOMEM; > >>> } > >>> acomp = crypto_alloc_acomp(pool->tfm_name, 0, 0); > >>> - if (IS_ERR_OR_NULL(acomp)) { > >>> + if (!acomp) { > >> > >> This should be IS_ERR(acomp). Please preserve the error code. > >> > >>> pr_err("could not alloc crypto acomp %s : %ld\n", > >>> pool->tfm_name, PTR_ERR(acomp)); > >>> - return -ENOMEM; > >>> + goto free_acomp_ctx; > >>> } > >>> acomp_ctx->acomp = acomp; > >>> > >>> req = acomp_request_alloc(acomp_ctx->acomp); > >>> - if (IS_ERR_OR_NULL(req)) { > >>> + if (!req) { > >>> pr_err("could not alloc crypto acomp %s : %ld\n", > >>> pool->tfm_name, PTR_ERR(acomp)); > >>> - return -ENOMEM; > >>> + goto free_acomp; > >>> } > >>> acomp_ctx->req = req; > >>> > >>> @@ -462,6 +462,12 @@ static int zswap_cpu_comp_prepare(unsigned int > >> cpu, struct hlist_node *node) > >>> *per_cpu_ptr(pool->acomp_ctx, cpu) = acomp_ctx; > >>> > >>> return 0; > >>> + > >>> +free_acomp: > >>> + kfree(acomp); > >> > >> The kfree() isn't correct. It needs to be: > >> > >> crypto_free_acomp(acomp); > >> > >>> +free_acomp_ctx: > >>> + kfree(acomp_ctx); > >>> + return -ENOMEM; > >> > >> regards, > >> dan carpenter > > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vitaly Wool Date: Tue, 23 Jun 2020 14:02:29 +0000 Subject: Re: [PATCH][next] mm/zswap: fix a couple of memory leaks and rework kzalloc failure check Message-Id: List-Id: References: <20200622153546.49880-1-colin.king@canonical.com> <20200622182816.GF4151@kadam> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Colin Ian King Cc: "Song Bao Hua (Barry Song)" , Dan Carpenter , Seth Jennings , Dan Streetman , Andrew Morton , Stephen Rothwell , "linux-mm@kvack.org" , "kernel-janitors@vger.kernel.org" , "linux-kernel@vger.kernel.org" On Tue, Jun 23, 2020, 1:12 PM Colin Ian King wrote: > > On 22/06/2020 20:55, Song Bao Hua (Barry Song) wrote: > > > > > >> -----Original Message----- > >> From: Dan Carpenter [mailto:dan.carpenter@oracle.com] > >> Sent: Tuesday, June 23, 2020 6:28 AM > >> To: Colin King > >> Cc: Seth Jennings ; Dan Streetman > >> ; Vitaly Wool ; Andrew > >> Morton ; Song Bao Hua (Barry Song) > >> ; Stephen Rothwell ; > >> linux-mm@kvack.org; kernel-janitors@vger.kernel.org; > >> linux-kernel@vger.kernel.org > >> Subject: Re: [PATCH][next] mm/zswap: fix a couple of memory leaks and > >> rework kzalloc failure check > >> > >> On Mon, Jun 22, 2020 at 04:35:46PM +0100, Colin King wrote: > >>> From: Colin Ian King > >>> > >>> kzalloc failures return NULL on out of memory errors, so replace the > >>> IS_ERR_OR_NULL check with the usual null pointer check. Fix two memory > >>> leaks with on acomp and acomp_ctx by ensuring these objects are free'd > >>> on the error return path. > >>> > >>> Addresses-Coverity: ("Resource leak") > >>> Fixes: d4f86abd6e35 ("mm/zswap: move to use crypto_acomp API for > >> hardware acceleration") > >>> Signed-off-by: Colin Ian King > > > > > > Colin, thanks for your patch. I am sorry I did the same thing with you here: > > https://lkml.org/lkml/2020/6/22/347 > > Thanks for fixing this correctly, I ran out of time yesterday to re-do > the fix. > > Colin I think this has gotten out of hand. Barry, could you please come up with a replacement for the initial patch rather than doing it incrementally? Thanks, Vitaly > > > > > > >>> --- > >>> mm/zswap.c | 16 +++++++++++----- > >>> 1 file changed, 11 insertions(+), 5 deletions(-) > >>> > >>> diff --git a/mm/zswap.c b/mm/zswap.c > >>> index 0d914ba6b4a0..14839cbac7ff 100644 > >>> --- a/mm/zswap.c > >>> +++ b/mm/zswap.c > >>> @@ -433,23 +433,23 @@ static int zswap_cpu_comp_prepare(unsigned int > >> cpu, struct hlist_node *node) > >>> return 0; > >>> > >>> acomp_ctx = kzalloc(sizeof(*acomp_ctx), GFP_KERNEL); > >>> - if (IS_ERR_OR_NULL(acomp_ctx)) { > >>> + if (!acomp_ctx) { > >>> pr_err("Could not initialize acomp_ctx\n"); > >>> return -ENOMEM; > >>> } > >>> acomp = crypto_alloc_acomp(pool->tfm_name, 0, 0); > >>> - if (IS_ERR_OR_NULL(acomp)) { > >>> + if (!acomp) { > >> > >> This should be IS_ERR(acomp). Please preserve the error code. > >> > >>> pr_err("could not alloc crypto acomp %s : %ld\n", > >>> pool->tfm_name, PTR_ERR(acomp)); > >>> - return -ENOMEM; > >>> + goto free_acomp_ctx; > >>> } > >>> acomp_ctx->acomp = acomp; > >>> > >>> req = acomp_request_alloc(acomp_ctx->acomp); > >>> - if (IS_ERR_OR_NULL(req)) { > >>> + if (!req) { > >>> pr_err("could not alloc crypto acomp %s : %ld\n", > >>> pool->tfm_name, PTR_ERR(acomp)); > >>> - return -ENOMEM; > >>> + goto free_acomp; > >>> } > >>> acomp_ctx->req = req; > >>> > >>> @@ -462,6 +462,12 @@ static int zswap_cpu_comp_prepare(unsigned int > >> cpu, struct hlist_node *node) > >>> *per_cpu_ptr(pool->acomp_ctx, cpu) = acomp_ctx; > >>> > >>> return 0; > >>> + > >>> +free_acomp: > >>> + kfree(acomp); > >> > >> The kfree() isn't correct. It needs to be: > >> > >> crypto_free_acomp(acomp); > >> > >>> +free_acomp_ctx: > >>> + kfree(acomp_ctx); > >>> + return -ENOMEM; > >> > >> regards, > >> dan carpenter > > > From mboxrd@z Thu Jan 1 00:00:00 1970 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=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 5180EC433DF for ; Tue, 23 Jun 2020 14:03:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0506020720 for ; Tue, 23 Jun 2020 14:03:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=konsulko.com header.i=@konsulko.com header.b="JvX0MDxx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0506020720 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 98FE26B0002; Tue, 23 Jun 2020 10:03:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 919AF6B0005; Tue, 23 Jun 2020 10:03:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E1616B0006; Tue, 23 Jun 2020 10:03:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 64D446B0002 for ; Tue, 23 Jun 2020 10:03:24 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1213976E22 for ; Tue, 23 Jun 2020 14:03:24 +0000 (UTC) X-FDA: 76960643928.29.lock76_0901a6a26e3c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id F3B1418058FE2 for ; Tue, 23 Jun 2020 14:02:44 +0000 (UTC) X-HE-Tag: lock76_0901a6a26e3c X-Filterd-Recvd-Size: 6790 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Tue, 23 Jun 2020 14:02:43 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id 9so23591734ljc.8 for ; Tue, 23 Jun 2020 07:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+mDKHqL9XaZmj7XcsJJwYzkkEK6i2Pe8R8fplxjQ0ik=; b=JvX0MDxxQ7q45iyUquGhnRAfIa6C8NJAargxgnJLVJ1QKDLMHSQdE4DHqkXQDQQvMA 0BlItz+1HrqAU843jnYC7PfhRIxKT0JH19lnfBaqxGSiKEfVwkV0H5AeiwaryqbwipQ+ n5g+jwL4+9Joj4DgkA5NywYvIjzDIitw+83lU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+mDKHqL9XaZmj7XcsJJwYzkkEK6i2Pe8R8fplxjQ0ik=; b=YU7E5Rt3XnfVr+7DdWkZvkTxKLpgQ+KUC/wGhQio+nMyOOmzApghhRVf+NurCUW+zZ cQ1yoaCG8X5T42dCXuNkIILRY7j7TZjI02Lv3nolQiVdTXHsG3GxQr70gJcFsh1ZU/t3 tteKhldEbhxz2+KBEV1xgTCpMHPUlYsdVOgYmwaHWQN9DBawmdq5vgmH/NZ0gHqSTPkP 32eusZFDTH+1WBuc3/BTdXd6x2yWppJIkpeZFUSkSKU5QZZrTmU5dmj4gNO/SVqfx656 R4PhB7jQ7D9bWKF/uRKSu35zWi3qECUWKzOvFVOLwO5CFgKMs2ou+r+UEK7v09BGBpX9 SwVg== X-Gm-Message-State: AOAM530eOfTCB/iG3LkMh1OX4vXGcfrifQIXCxVbtE4f83MBdG5MwB3J +U3LjzGOF+GEfTTRMg6H4QelyhwSNnT/N5sABRYqXQ== X-Google-Smtp-Source: ABdhPJwkp7xO233qrwVR3p5tSB1yZTt9QFCbp0qjfLwtRcyVzpREtRGELz74ul+4qEqtniyRgrWITwvGeGjIWMKuSHU= X-Received: by 2002:a2e:3603:: with SMTP id d3mr10508629lja.259.1592920961167; Tue, 23 Jun 2020 07:02:41 -0700 (PDT) MIME-Version: 1.0 References: <20200622153546.49880-1-colin.king@canonical.com> <20200622182816.GF4151@kadam> In-Reply-To: From: Vitaly Wool Date: Tue, 23 Jun 2020 16:02:29 +0200 Message-ID: Subject: Re: [PATCH][next] mm/zswap: fix a couple of memory leaks and rework kzalloc failure check To: Colin Ian King Cc: "Song Bao Hua (Barry Song)" , Dan Carpenter , Seth Jennings , Dan Streetman , Andrew Morton , Stephen Rothwell , "linux-mm@kvack.org" , "kernel-janitors@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: F3B1418058FE2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: On Tue, Jun 23, 2020, 1:12 PM Colin Ian King wrote: > > On 22/06/2020 20:55, Song Bao Hua (Barry Song) wrote: > > > > > >> -----Original Message----- > >> From: Dan Carpenter [mailto:dan.carpenter@oracle.com] > >> Sent: Tuesday, June 23, 2020 6:28 AM > >> To: Colin King > >> Cc: Seth Jennings ; Dan Streetman > >> ; Vitaly Wool ; Andrew > >> Morton ; Song Bao Hua (Barry Song) > >> ; Stephen Rothwell ; > >> linux-mm@kvack.org; kernel-janitors@vger.kernel.org; > >> linux-kernel@vger.kernel.org > >> Subject: Re: [PATCH][next] mm/zswap: fix a couple of memory leaks and > >> rework kzalloc failure check > >> > >> On Mon, Jun 22, 2020 at 04:35:46PM +0100, Colin King wrote: > >>> From: Colin Ian King > >>> > >>> kzalloc failures return NULL on out of memory errors, so replace the > >>> IS_ERR_OR_NULL check with the usual null pointer check. Fix two memory > >>> leaks with on acomp and acomp_ctx by ensuring these objects are free'd > >>> on the error return path. > >>> > >>> Addresses-Coverity: ("Resource leak") > >>> Fixes: d4f86abd6e35 ("mm/zswap: move to use crypto_acomp API for > >> hardware acceleration") > >>> Signed-off-by: Colin Ian King > > > > > > Colin, thanks for your patch. I am sorry I did the same thing with you here: > > https://lkml.org/lkml/2020/6/22/347 > > Thanks for fixing this correctly, I ran out of time yesterday to re-do > the fix. > > Colin I think this has gotten out of hand. Barry, could you please come up with a replacement for the initial patch rather than doing it incrementally? Thanks, Vitaly > > > > > > >>> --- > >>> mm/zswap.c | 16 +++++++++++----- > >>> 1 file changed, 11 insertions(+), 5 deletions(-) > >>> > >>> diff --git a/mm/zswap.c b/mm/zswap.c > >>> index 0d914ba6b4a0..14839cbac7ff 100644 > >>> --- a/mm/zswap.c > >>> +++ b/mm/zswap.c > >>> @@ -433,23 +433,23 @@ static int zswap_cpu_comp_prepare(unsigned int > >> cpu, struct hlist_node *node) > >>> return 0; > >>> > >>> acomp_ctx = kzalloc(sizeof(*acomp_ctx), GFP_KERNEL); > >>> - if (IS_ERR_OR_NULL(acomp_ctx)) { > >>> + if (!acomp_ctx) { > >>> pr_err("Could not initialize acomp_ctx\n"); > >>> return -ENOMEM; > >>> } > >>> acomp = crypto_alloc_acomp(pool->tfm_name, 0, 0); > >>> - if (IS_ERR_OR_NULL(acomp)) { > >>> + if (!acomp) { > >> > >> This should be IS_ERR(acomp). Please preserve the error code. > >> > >>> pr_err("could not alloc crypto acomp %s : %ld\n", > >>> pool->tfm_name, PTR_ERR(acomp)); > >>> - return -ENOMEM; > >>> + goto free_acomp_ctx; > >>> } > >>> acomp_ctx->acomp = acomp; > >>> > >>> req = acomp_request_alloc(acomp_ctx->acomp); > >>> - if (IS_ERR_OR_NULL(req)) { > >>> + if (!req) { > >>> pr_err("could not alloc crypto acomp %s : %ld\n", > >>> pool->tfm_name, PTR_ERR(acomp)); > >>> - return -ENOMEM; > >>> + goto free_acomp; > >>> } > >>> acomp_ctx->req = req; > >>> > >>> @@ -462,6 +462,12 @@ static int zswap_cpu_comp_prepare(unsigned int > >> cpu, struct hlist_node *node) > >>> *per_cpu_ptr(pool->acomp_ctx, cpu) = acomp_ctx; > >>> > >>> return 0; > >>> + > >>> +free_acomp: > >>> + kfree(acomp); > >> > >> The kfree() isn't correct. It needs to be: > >> > >> crypto_free_acomp(acomp); > >> > >>> +free_acomp_ctx: > >>> + kfree(acomp_ctx); > >>> + return -ENOMEM; > >> > >> regards, > >> dan carpenter > > >