Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6257912rwb; Mon, 14 Nov 2022 17:14:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf4mvBtBvi/c0rKttgWTVTRYTILn0WvqglCZGNGX16giijKA8k1wlxaJDuIoXoA65knkfzk3 X-Received: by 2002:a65:5b8a:0:b0:476:8796:88 with SMTP id i10-20020a655b8a000000b0047687960088mr5871615pgr.29.1668474861653; Mon, 14 Nov 2022 17:14:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668474861; cv=none; d=google.com; s=arc-20160816; b=RmOtVeMiKlY0oofcxr0SALsuY1nriELDvUmJJwGKUwu4L7m5TAz32CnhKiLTIwX5bR L/1RV7CMyHzw2CLasoJAj2T8JyEOJa0DVcp/zUe8v7p4Liwgb7AHvAUKk3lIrW301WI3 bdb+es8nkaJoj3XGRZbo0LT1kTUwLVZ7rAnX7afssbCfeZEtHJNbUP+036G7glJ/oZw9 LYOeYUd09U7nnmproEEkw6goUC+anl9ULaXfxVw5aRHvtGb0E83fP/z0Jivm0yc41Y+W V4i/7qvg/zKkiJfxRmJdl/fI/1bgZ8rBwwQIXJqtixVPTSK+kbVQ+EexCL0Jzl1d7byR +glg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ZoxcZLmzsq83+rHNWuzABJOjX7MklD2wIzx4GvWNeCY=; b=dKjq5Qv2crxF5O/1QTarOUpBuR83kZDjwj0tFjWr0Xik5duhYdZxbyAI7GDytZ49od PVHXZK+XQMvLbB99Hy+MhniDdqiQsOCgqecR5bBmN2qyjIdhOglJwFhTnIxWJi7B/RLF /9P9aUu/KYIY0TCIaolF1skbokppJ2FbzOyB1YRe+UPk/Q7A7KijtGaj+XuAreVANiTz uZxr31/mrgBXWiNP0S+BUAo7s6KTuc1p1U9QKgXEjC+EzO67AU+g9bcW1uamEn1cOMre ioPNG7xcrLlc4nF1j/r0pngzPirXu3z2K5xQQOuxyFTAW9DZBchtxzSiQXiXfmKF4vTk 4Ubw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=iyzZeB2H; 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=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x131-20020a633189000000b0045ceb2c2eb7si11824716pgx.760.2022.11.14.17.13.58; Mon, 14 Nov 2022 17:14:21 -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; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=iyzZeB2H; 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=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231254AbiKOBK7 (ORCPT + 99 others); Mon, 14 Nov 2022 20:10:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230199AbiKOBK6 (ORCPT ); Mon, 14 Nov 2022 20:10:58 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6279CF5BB for ; Mon, 14 Nov 2022 17:10:55 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id m6so12726465pfb.0 for ; Mon, 14 Nov 2022 17:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ZoxcZLmzsq83+rHNWuzABJOjX7MklD2wIzx4GvWNeCY=; b=iyzZeB2HIwzW+rGfh2nFI825HJA5s0hyO6y42jBoY4eYD7JAzLEiLIkC3NSVG78BKc mQDssF8RtvFCb/94yM35OxP/RSkKEbFVbHiZ5dm12cGVH6D1/2beJ4aIRJWivDKN0UMJ A/ovm6OMDHgEYtFRVJ9zjFLQi5oFATo1c9dQX8fGpnRXsgfxVx2fihRBk8w3xZwCN2YD q2BOce+mDlq76+h6kfh4/NwAmgBcGMUFzyXQHzaljFRlH2XwDgg9BRkM4QiM5TR+Y262 TD1V6CO87waIBRLqhxMozbhWNrV8oEG8ndSF16TyCrwcPLt11GPyftBFvLk5f52TACV1 9OXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZoxcZLmzsq83+rHNWuzABJOjX7MklD2wIzx4GvWNeCY=; b=LHnU8n7t4aRh8QURAezO3DQHwMGNsUv6g/Hap+VRpQTL6m/wsajCkvgurT6Yg1asXx zlxyhayjaEEiemkOVgKlX6ONYOQWXoMj0XXeu8L/7Z0AC+B2tnQhsDiwMa2YoDsVIx8d WKey2Iwg3Aeh1UUGvSY4GPNmh5Mq1S8E3kzt41x2iP15rTxCWHSzY1OXYs45samtgc1d zHikEj7JvEWmKalIPjSvseOqgT/8isWV5y2JYQ/Yn6oKzhZd5KxHeh0LA8lj3dvIcUph gGZMqkl5JLOfA4QuvnSpkxVWumy2N3R9mNX197mATkhmZGZ0tMhGkrG8vhjlU/lzFp1+ qvbw== X-Gm-Message-State: ANoB5pl/lo0mfObKSEZDD4+GIQIZr84T+yyOsFwo3IOJSmTaMimsjdrv DxweEypQYHawQlTVdsVOcomGTg== X-Received: by 2002:a63:d457:0:b0:476:837b:7a08 with SMTP id i23-20020a63d457000000b00476837b7a08mr6159794pgj.430.1668474654884; Mon, 14 Nov 2022 17:10:54 -0800 (PST) Received: from [10.3.43.196] ([63.216.146.186]) by smtp.gmail.com with ESMTPSA id jm5-20020a17090304c500b00186b758c9fasm8201015plb.33.2022.11.14.17.10.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Nov 2022 17:10:54 -0800 (PST) Message-ID: <0cc9f344-44ff-284f-391e-dcf756d74471@bytedance.com> Date: Tue, 15 Nov 2022 09:09:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] virtio-crypto: fix memory leak in virtio_crypto_alg_skcipher_close_session() To: Wei Yongjun , "Michael S. Tsirkin" , Gonglei Cc: Wei Yongjun , virtualization@lists.linux-foundation.org, linux-crypto@vger.kernel.org, Jason Wang , "David S. Miller" , Herbert Xu References: <20221114110740.537276-1-weiyongjun@huaweicloud.com> Content-Language: en-US From: zhenwei pi In-Reply-To: <20221114110740.537276-1-weiyongjun@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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 Looks good to me, thanks! Acked-by: zhenwei pi On 11/14/22 19:07, Wei Yongjun wrote: > 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; > } > > err = 0; -- zhenwei pi