Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp705663img; Thu, 21 Mar 2019 07:18:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqgeETz3I9v4PXfTmin7H0Ld3DCrB3cPwX5JNvqskdbvyauhQi8rDvKBO3O+ZSlYrvN+1c X-Received: by 2002:a62:be02:: with SMTP id l2mr3610205pff.55.1553177930753; Thu, 21 Mar 2019 07:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553177930; cv=none; d=google.com; s=arc-20160816; b=ep6E0gcvSArhGb67dhh4vIxgT0kHlLN1DQnuOD/eZV+4onoy5mks2lw2aCJ70I0z7Q 6yqBl+DdMLW/WSL4pdDOr8ade57hHBkuO+xhJQKUJSnSrctca6xX/B0JU6q0uLzwN/R9 pFJDb81kyUv9y6onagHT4X5b2KY/u1KPyfQQasRY6v4dIokb2GNZDvy8QB8dj/IS0mnz h1STLEpBy77Ah+VqhYLjQ7EiX0FdgvKPjCsrqPqxrgNYZtPyHLtheetz0lhw11ymRyZk nf/0V1LRj8Ullg8XKLw9D8Ij2TysUlqHLfsf3I97V50mGIWnlQc6oIkDCUNqoMuQHZt4 C8YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=5y90Dspig8sHmbMxd8hN/S25eIh3KSdwvmCRVcBGTpQ=; b=HQJNo0mYpmpPALEKbsuRZwV4nZ+z1IiTaSnpbIY8IEb5UMvK2qxztBDKksxBlaYkJE 7m5qpX8rAZAu1B69ForT2ir+jvj6RTH3/yzT0Dloa0TknY9DSda3pUGT9HW2EWwUurXL hbLhHH+JZp1IpuS4R/bgwbEDNBTOODS2scpscASzhWEZZFh/XGCsQC00vAUcZaIRM0hc 39wGYEQrP7ScfVBf63XGKsceVmiMlayQhvqbXKAuryOQyFxWQ4BhpfhWRBeJaWJmBoyV hTAJWMTgMzIku5slLB9Y9UFDi04LTaUWAETGmfsWcFkI9sA+DdX/mqlRlSMogE5E2h3t rLXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k24si4213008pgj.228.2019.03.21.07.18.35; Thu, 21 Mar 2019 07:18:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728316AbfCUOQW (ORCPT + 99 others); Thu, 21 Mar 2019 10:16:22 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:35160 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726551AbfCUOQV (ORCPT ); Thu, 21 Mar 2019 10:16:21 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2C3FCCA1BF7C77555969; Thu, 21 Mar 2019 22:11:18 +0800 (CST) Received: from localhost (10.177.31.96) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 22:11:07 +0800 From: Yue Haibing To: , CC: , , , YueHaibing Subject: [PATCH] dccp: Fix memleak in __feat_register_sp Date: Thu, 21 Mar 2019 22:10:58 +0800 Message-ID: <20190321141058.14580-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: YueHaibing If dccp_feat_push_change fails, we forget free the mem which is alloced by kmemdup in dccp_feat_clone_sp_val. Reported-by: Hulk Robot Fixes: e8ef967a54f4 ("dccp: Registration routines for changing feature values") Signed-off-by: YueHaibing --- net/dccp/feat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/dccp/feat.c b/net/dccp/feat.c index f227f00..083e012 100644 --- a/net/dccp/feat.c +++ b/net/dccp/feat.c @@ -738,7 +738,12 @@ static int __feat_register_sp(struct list_head *fn, u8 feat, u8 is_local, if (dccp_feat_clone_sp_val(&fval, sp_val, sp_len)) return -ENOMEM; - return dccp_feat_push_change(fn, feat, is_local, mandatory, &fval); + if (dccp_feat_push_change(fn, feat, is_local, mandatory, &fval)) { + kfree(val->sp.vec); + return -ENOMEM; + } + + return 0; } /** -- 2.7.0