Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5350052rwb; Mon, 14 Nov 2022 03:23:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf4UwrZjlyNXDYwfAFfz4YW1ljqKKwEdkDMSrrNz+zuz7eSPaAsHWSpIebPHI7eXDN4EETff X-Received: by 2002:a17:906:ecfb:b0:7a6:cf13:ccba with SMTP id qt27-20020a170906ecfb00b007a6cf13ccbamr9669665ejb.432.1668425033274; Mon, 14 Nov 2022 03:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668425033; cv=none; d=google.com; s=arc-20160816; b=qyy6b9sA0lf+cXBo6R25vVKa0W7za/R1BWcDoX5S2ILa6i71LljnUPUz0ogiHUTJUZ LpDDQ4Pgw+nM0U56wMgZf4S8oiNEmPefeCoccJdbaov0tw1Q/EfyKXLGkXemSXOF0PvN GTZyJSbYd34Ickw/SRhmcEMGs7/ZRnV64ZLuKHH106w/2nNK/RNfxh4/aZJRn5OTQdze eu6nF4RGdn3BbAAFs7g7f11+Ao4uvugzqwCCgwsJftljRAYNXB5snZC6e7pUoERlCs4e pCdJnkcg9qsDA6usJvySE/gsSxQh1wWpV3OgTW0RSCCBkPlMC5xvPh91/sdV081HD1ig NeHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=M8ArYmUbcbbD6iI5hD2sjspeL/mTSIEXX1x7gt+CQxU=; b=v+Nn43Cc4JMOy8GzLj/z4g4sN0RkWgRpmgDOMwFMujvKYTAd/BOCJgChOKM12RReSr eLR579Mhsb75fuAUMvnjPdH+vQ+TE09eHJbqDua4xa+33+REB3EtjPRloRTq0WK+GQxH j1+oIWTBLW7su7yZWJQ1QPO7zV+1MnmtsH9AC40dIZY7Po7Sx1HpWfkDvbIyJOPLJSUq 2ZN2N+tckNgm7OiNAi3Jg85hXALxsxs2wv5JExAqWvijX7epRjRh8TmghmNuE4YPBaNS fdePcxyZVlQoW6Zu9Pwp2miDcCrybQ+eA0OWh3NpZeD5Bcu1/R4mpi3WE73kJ/0hkI7i CWIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc16-20020a170907169000b00741a18d4a5asi9865394ejc.994.2022.11.14.03.23.25; Mon, 14 Nov 2022 03:23:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236418AbiKNLWa convert rfc822-to-8bit (ORCPT + 99 others); Mon, 14 Nov 2022 06:22:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236468AbiKNLWG (ORCPT ); Mon, 14 Nov 2022 06:22:06 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72AFD115E for ; Mon, 14 Nov 2022 03:18:37 -0800 (PST) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4N9myJ6GFTz15Mc6; Mon, 14 Nov 2022 19:18:16 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 14 Nov 2022 19:18:35 +0800 Received: from dggpemm500006.china.huawei.com ([7.185.36.236]) by dggpemm500006.china.huawei.com ([7.185.36.236]) with mapi id 15.01.2375.031; Mon, 14 Nov 2022 19:18:35 +0800 From: "Gonglei (Arei)" To: Wei Yongjun , "Michael S. Tsirkin" , Jason Wang , Herbert Xu , "David S. Miller" , zhenwei pi CC: "weiyongjun (A)" , "virtualization@lists.linux-foundation.org" , "linux-crypto@vger.kernel.org" Subject: RE: [PATCH] virtio-crypto: fix memory leak in virtio_crypto_alg_skcipher_close_session() Thread-Topic: [PATCH] virtio-crypto: fix memory leak in virtio_crypto_alg_skcipher_close_session() Thread-Index: AQHY+Bk7XRuE0LikA0eoAQIv/q8hvK4+RQHw Date: Mon, 14 Nov 2022 11:18:35 +0000 Message-ID: <06d31ec507ef441abc4dc56f2c9be8ac@huawei.com> References: <20221114110740.537276-1-weiyongjun@huaweicloud.com> In-Reply-To: <20221114110740.537276-1-weiyongjun@huaweicloud.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.149.11] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org > -----Original Message----- > From: Wei Yongjun [mailto:weiyongjun@huaweicloud.com] > Sent: Monday, November 14, 2022 7:08 PM > To: Michael S. Tsirkin ; Jason Wang > ; Gonglei (Arei) ; > Herbert Xu ; David S. Miller > ; zhenwei pi > Cc: weiyongjun (A) ; > virtualization@lists.linux-foundation.org; linux-crypto@vger.kernel.org > Subject: [PATCH] virtio-crypto: fix memory leak in > virtio_crypto_alg_skcipher_close_session() > > From: Wei Yongjun > > 'vc_ctrl_req' is alloced in virtio_crypto_alg_skcipher_close_session(), > and should be freed in the invalid ctrl_status->status error handling case. > Otherwise there is a memory leak. > > Fixes: 0756ad15b1fe ("virtio-crypto: use private buffer for control request") > Signed-off-by: Wei Yongjun > --- > drivers/crypto/virtio/virtio_crypto_skcipher_algs.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c > b/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c > index e553ccadbcbc..e5876286828b 100644 > --- a/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c > +++ b/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c > @@ -239,7 +239,8 @@ static int virtio_crypto_alg_skcipher_close_session( > pr_err("virtio_crypto: Close session failed status: %u, session_id: > 0x%llx\n", > ctrl_status->status, destroy_session->session_id); > > - return -EINVAL; > + err = -EINVAL; > + goto out; > } > Good catch. Reviewed-by: Gonglei Regards, -Gonglei > err = 0; > -- > 2.34.1