Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6505589rwb; Mon, 14 Nov 2022 22:31:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf5pOjLXWDEggkKEgLkG1bkLLwuSZP4SmI7vwBreRXWRF5nNVvhlt1H6TI/nXqCYdCH8G65Y X-Received: by 2002:a63:fb0e:0:b0:46f:13b0:8dab with SMTP id o14-20020a63fb0e000000b0046f13b08dabmr14752948pgh.497.1668493882180; Mon, 14 Nov 2022 22:31:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668493882; cv=none; d=google.com; s=arc-20160816; b=R0Sex6V0/gbwZxPvONFdzoKyDT91fheTMufEWBV/8Pus50NHCtd8IFYnPXrFhvl+TM 1tmrFI75vr+PoA2AY0P1SoWjTtbIbJTXHTchJ1vtPIgKgwmedz9+hWkozwiXCxZ07NJq LEXCgJDt6We5NpGu3m8mdahhnIBkYhl8SnXd21UH46PY+aDCpidUosrnCPrQ4mGNll16 VQdCKcYFyyxkvHDM5qxL327Z+Flp0VXVJMCKg/xGjKVzZQeluyhwU/UuI1COTSE3L8TF BEfDIy7W6a+xm2FUCQZAn53IH+95qX2gG794JaJgtl3f+2N03CPq3Wkj4dXG6i7YbanS Vqxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=gaUjUy0cAk82v0uahWp+GaCbWFfU6R/rouT9IrYbegg=; b=ESr/WHg7/5DFAcbLREQWMNZAtXRbJ2LuqCqTF7JndWkuX2MEjMjkcm4HgnucWush06 jDay1FD1K851PjecDqpOns0r1tSmQs4olJlgScmHwH2FsAArhJTDmFYc4IynOoWf+zmf PRmDGojwM+PGeMQqxyHdL3jWdfnfQ5yPp68cIlElSAnGgYR+VhttPc5tv55bCWcn98RE X0oA+H/DZJXm/qEItrwuQ/69uh46AfJJfkgayn2pGUM1BZHffqcZDDw+NLxA5cO1xkvZ S2fG8C0hCLPAhL1i+5k1edr0RBbyitv7OnYHyXHXu7ZOfPQegKkUA8fAa1/1LVGGRBg9 PCGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AWsY4qtL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a170902c40400b001889ad48288si11584594plk.384.2022.11.14.22.30.57; Mon, 14 Nov 2022 22:31:22 -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=@redhat.com header.s=mimecast20190719 header.b=AWsY4qtL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232238AbiKOG3A (ORCPT + 99 others); Tue, 15 Nov 2022 01:29:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232174AbiKOG25 (ORCPT ); Tue, 15 Nov 2022 01:28:57 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B85671EED8 for ; Mon, 14 Nov 2022 22:28:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668493684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gaUjUy0cAk82v0uahWp+GaCbWFfU6R/rouT9IrYbegg=; b=AWsY4qtL8Op6/8DVQGPOzBzF/v1ASHZ0hNCxgdMensuBlrbyE1Hkt3hagIvyqOo2s0gRP1 cIcZVnhbgcZwuOV+SXcPqHIfcUxpku0HjQDUdbeMB8DKQLSrSRHYpBhwck3h7zEvCsWmD7 weFA3p485aKHe0ExqjytK4dJXKKdAU0= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-30-NejiPD-6NZONaUiOxeZJ0Q-1; Tue, 15 Nov 2022 01:28:03 -0500 X-MC-Unique: NejiPD-6NZONaUiOxeZJ0Q-1 Received: by mail-oi1-f198.google.com with SMTP id be25-20020a056808219900b0035ad466a313so2793268oib.17 for ; Mon, 14 Nov 2022 22:28:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gaUjUy0cAk82v0uahWp+GaCbWFfU6R/rouT9IrYbegg=; b=jH5bYRmZvL8HTP4DmNclAxJWxyRbBYgPHPRNZ9px4EhpQA69OfOCG5byIIGkTQ0Asz XvdHUnG8akTdSAQN6ave7HfhSEYdTmHdQRvI4heSUGRGMjpU+25fvVOr6QEm1WW0QbUZ VMut10hjG0ZOB1OoCgK0FTNdZU27/oWb1T/VUqX8aWtOAmUUi/alG9oJdbqaEoij36gB TqbqXUiq+5xg7A2dH8xv5DElHDWXXXVBIAHkhKpLYNf9ND+3SnTmOM3bnWM3DvmRAhQX BMnyVGcj6tlxlGSs6VsvBPUNX6CS55ESsT0NXf2Y5fn4bmYSa8FZbsZ7qzmU/Wt/R3KK qheA== X-Gm-Message-State: ANoB5pk3JEGx6gvAOTwwO2VHKznWfbZliwhhDoqjtYWRqa1ORXlmVqqd 67J1FMwU21Va4k52/FSA6mEJ0oSzok72hdcDooL3m/kQQdQojJPzfUoPErw2fCYCWP/ZSG7whYK MxviB/tUNvWLC3zGrefCB59V7wGCSX1dis4+wpD72 X-Received: by 2002:a05:6870:638b:b0:132:7b3:29ac with SMTP id t11-20020a056870638b00b0013207b329acmr20143oap.35.1668493681906; Mon, 14 Nov 2022 22:28:01 -0800 (PST) X-Received: by 2002:a05:6870:638b:b0:132:7b3:29ac with SMTP id t11-20020a056870638b00b0013207b329acmr20136oap.35.1668493681696; Mon, 14 Nov 2022 22:28:01 -0800 (PST) MIME-Version: 1.0 References: <20221114110740.537276-1-weiyongjun@huaweicloud.com> In-Reply-To: <20221114110740.537276-1-weiyongjun@huaweicloud.com> From: Jason Wang Date: Tue, 15 Nov 2022 14:27:50 +0800 Message-ID: Subject: Re: [PATCH] virtio-crypto: fix memory leak in virtio_crypto_alg_skcipher_close_session() To: Wei Yongjun Cc: "Michael S. Tsirkin" , Gonglei , Herbert Xu , "David S. Miller" , zhenwei pi , Wei Yongjun , virtualization@lists.linux-foundation.org, linux-crypto@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 On Mon, Nov 14, 2022 at 7:26 PM 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 Acked-by: Jason Wang Thanks > --- > 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; > -- > 2.34.1 >