Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2936133ybb; Mon, 30 Mar 2020 16:27:49 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsl8dkojLOyBI7YPP6o1UuN+93aiFoKDXhG+r1XVTJgtleLGSGVMtSolGLd62vKKKAE55xR X-Received: by 2002:a9d:1988:: with SMTP id k8mr1296624otk.4.1585610869325; Mon, 30 Mar 2020 16:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585610869; cv=none; d=google.com; s=arc-20160816; b=LFrn7y+8wa8vyICnbogVenxB3/dnjVCuuiaXznAoudJkiODr86ekZCTgTV0g9BSUb2 z2hsWi39yqORi3N1+GG9v8wxYFZl3rYaKUEt4BmFQD0w5i+bahmSTebUL6sRcmfAtc4T JT10qQ0haB43aJ0zGFPOerB2TN0wnUahKJGb/jz0JPL1eYfJL6Fx22bGACc+w/YiGm8N ApDoSNbQzVgZzhEgU0c+fmuJoHJB16Jye9TkomiXJ9XB9mVxL6qjdpFHbgYwEca8348U vlLQ0tIolc3n2gbbQNvHLu377D599JfpegEWeMoEHZs8nGzqIxkhLPhYU2Bu6V8cZphz HIlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=xhDG3dLN6Yo/RcJTREoCUsHNM+lDjok6pPw8Y/2IHM8=; b=SvnaMSi3oUE5xtZUwjcZq7n0jTOV4e0zptC/lRh/CN8dTfD4Wa0M+FBeuk+ymPHY7Y 7ggxpQcT5pmLODchy5z0kpkr3RfaYAgOqBRr3zTcswTOWQump0r+ybq9WVviBm1UThCt NmwNlJAsqJwSPHHA02vL5/imOilz5AHE2IsT1ODRiK+RejzoXaJCcyRQT2UVuSJE4Wjf vF9sCCI+yUHD4p6cMhtV9590TCafuJuJx1BP9qy3DP+5BuiQXdd9xCKnX1tOn2S83qCd oYS6WuB/0q4oMCBc+4bJjicfHZshwOKjfJ0U6j3dmy0xoKdQPAowRD+ZXFvnbV/07xLz 6Siw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=MtlPW6u5; 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 67si6856284otj.108.2020.03.30.16.27.37; Mon, 30 Mar 2020 16:27:49 -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; dkim=fail header.i=@embeddedor.com header.s=default header.b=MtlPW6u5; 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 S1729408AbgC3X1H (ORCPT + 99 others); Mon, 30 Mar 2020 19:27:07 -0400 Received: from gateway33.websitewelcome.com ([192.185.145.9]:13160 "EHLO gateway33.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728876AbgC3X1H (ORCPT ); Mon, 30 Mar 2020 19:27:07 -0400 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 16EEA1E77 for ; Mon, 30 Mar 2020 18:27:06 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id J3oAjCmEKSl8qJ3oAjiyR3; Mon, 30 Mar 2020 18:27:06 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Type:MIME-Version:Message-ID:Subject: Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=xhDG3dLN6Yo/RcJTREoCUsHNM+lDjok6pPw8Y/2IHM8=; b=MtlPW6u5+hLcKOUUXlj4aIV1Rj 9B0gN5E8BYFgAboLKbVSMJv9CLzUllkbOGoJ5uVeFjdQyFcsKSgmb94YHCEluUiTLdiIvl1Iw9Kh7 UEysDtp3D/TKEt7UoawdP5pIKFmEHmuEMtb7KbEw87S5JLEHhtvync+0lQAgbAzrPAvDNlKdr0oTQ eA8UgVSLM4dW4VduF9LpxGAlWDgc4Tm3z3+eEsqipTPVemYbRNIL5Ke+1I5Z0C6OTZU+aRH6MqoX3 z4peADMt/7/RUsPjpqton+bGTUBsDpELiYI4qwLsuRc+1PGByVH7+q93N0/n5A3Oy6DSG1aAacQ1n mRKizwoQ==; Received: from cablelink-189-218-116-241.hosts.intercable.net ([189.218.116.241]:50684 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.92) (envelope-from ) id 1jJ3o8-000bhq-I6; Mon, 30 Mar 2020 18:27:04 -0500 Date: Mon, 30 Mar 2020 18:27:02 -0500 From: "Gustavo A. R. Silva" To: Jakub Kicinski , "David S. Miller" , Jacob Keller , Jiri Pirko Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH net-next] netdevsim: dev: Fix memory leak in nsim_dev_take_snapshot_write Message-ID: <20200330232702.GA3212@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.218.116.241 X-Source-L: No X-Exim-ID: 1jJ3o8-000bhq-I6 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cablelink-189-218-116-241.hosts.intercable.net (embeddedor) [189.218.116.241]:50684 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 6 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case memory resources for dummy_data were allocated, release them before return. Addresses-Coverity-ID: 1491997 ("Resource leak") Fixes: 7ef19d3b1d5e ("devlink: report error once U32_MAX snapshot ids have been used") Signed-off-by: Gustavo A. R. Silva --- drivers/net/netdevsim/dev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index 2b727a7001f6..9897e9a0e26f 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -75,6 +75,7 @@ static ssize_t nsim_dev_take_snapshot_write(struct file *file, err = devlink_region_snapshot_id_get(devlink, &id); if (err) { pr_err("Failed to get snapshot id\n"); + kfree(dummy_data); return err; } err = devlink_region_snapshot_create(nsim_dev->dummy_region, -- 2.23.0