Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp256198pxa; Thu, 27 Aug 2020 01:04:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcdi2buMg4b+cRY2cL0bryw1Pjux6N+u+3+GKgw4INnAF+B9A9lC11T1TArQIC+MnMUFpe X-Received: by 2002:a17:906:5205:: with SMTP id g5mr19270710ejm.488.1598515472605; Thu, 27 Aug 2020 01:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598515472; cv=none; d=google.com; s=arc-20160816; b=gujWQvsHX01D0hoCaw8R/cOv8Ck5MwPCkicK2tkSBPlsE8BQderDEI1sUbyuyLIJVO eiwL4HpHd+XbEpH3QqGuN9gq+FejgrsoAyS3EBbgGg7fvDv4GqJmYDU83X7EBiGsIMtc nWFKkPAHBPU+s7BRuE6veuPfVXZWKcFsTz9ThUuPcH2MqJK+3wsmntFCFnIHd04yYQDA zadIm1tk4A1mjl8eT82OFSNfEIMyqaMEn9NUt9DAHFkRSniQUoEBgdOrmPdwmGlBz8O0 XIxnLA5N1t9m5IAw7osuWQR/Mw7fgAlFnQP6yaxfroUQ7Alx6JEUnLZOQTwdB4/fbDAi unSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=JYSDOZE7n82x7cpANT179PQz0lava+8DZtL7G+W6LiQ=; b=FSGT+pSvziM14N+JMXq9mQI6toQeVW9YbHIm4VkMLUZtPA9sGpuWsnYF4FkTdMwdZI 6PoPmg5kdqqsUCqCRaq7nf9VT2OPyfrvuBNObyO8pbpOoT/PDMNv1JoGYbEUtdfSeDCG UP3VAbb7aVvjMjhYBhVEJWrh4iXY5xfJSC1konmYScyvoAX/D0Cj6Vq2JK/mgoLTSAgf EmO81POJSZvKX+XlxJGQc/quSABCtP9NgMq0kkrQxz5Is+6jaDBznyrS9GThSRmfVuHs Os+F2Tf26uFyU46z/540RJ7BUWXz6NnGxcWBvF2XzR8PpHGIlySn7BDooDrKH8CGW3+8 ldoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si1108191edr.470.2020.08.27.01.04.10; Thu, 27 Aug 2020 01:04:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728088AbgH0IDg (ORCPT + 99 others); Thu, 27 Aug 2020 04:03:36 -0400 Received: from spam.zju.edu.cn ([61.164.42.155]:20972 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727786AbgH0ID0 (ORCPT ); Thu, 27 Aug 2020 04:03:26 -0400 Received: from localhost.localdomain (unknown [210.32.144.184]) by mail-app4 (Coremail) with SMTP id cS_KCgCnHXmtaEdfNtlgAQ--.29784S4; Thu, 27 Aug 2020 16:02:57 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Trond Myklebust , Anna Schumaker , "J. Bruce Fields" , Chuck Lever , "David S. Miller" , Jakub Kicinski , Scott Mayhew , linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gss_krb5: Fix memleak in krb5_make_rc4_seq_num Date: Thu, 27 Aug 2020 16:02:50 +0800 Message-Id: <20200827080252.26396-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cS_KCgCnHXmtaEdfNtlgAQ--.29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UUUUU== X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAg0EBlZdtPrBDAAZsc Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When kmalloc() fails, cipher should be freed just like when krb5_rc4_setup_seq_key() fails. Fixes: e7afe6c1d486b ("sunrpc: fix 4 more call sites that were using stack memory with a scatterlist") Signed-off-by: Dinghao Liu --- net/sunrpc/auth_gss/gss_krb5_seqnum.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/auth_gss/gss_krb5_seqnum.c b/net/sunrpc/auth_gss/gss_krb5_seqnum.c index 507105127095..88ca58d11082 100644 --- a/net/sunrpc/auth_gss/gss_krb5_seqnum.c +++ b/net/sunrpc/auth_gss/gss_krb5_seqnum.c @@ -53,8 +53,10 @@ krb5_make_rc4_seq_num(struct krb5_ctx *kctx, int direction, s32 seqnum, return PTR_ERR(cipher); plain = kmalloc(8, GFP_NOFS); - if (!plain) - return -ENOMEM; + if (!plain) { + code = -ENOMEM; + goto out; + } plain[0] = (unsigned char) ((seqnum >> 24) & 0xff); plain[1] = (unsigned char) ((seqnum >> 16) & 0xff); -- 2.17.1