Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Dec 2018 13:41:37 +0000 (UTC)
From:      Slava Shwartsman <slavash@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r341556 - head/sys/dev/mlx5/mlx5_core
Message-ID:  <201812051341.wB5Dfb2E076724@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: slavash
Date: Wed Dec  5 13:41:37 2018
New Revision: 341556
URL: https://svnweb.freebsd.org/changeset/base/341556

Log:
  mlx5: Fix for potential memory leaks.
  
  Make sure allocated data gets freed in error cases.
  
  Submitted by:   hselasky@
  Approved by:    hselasky (mentor)
  MFC after:      1 week
  Sponsored by:   Mellanox Technologies

Modified:
  head/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
  head/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c
  head/sys/dev/mlx5/mlx5_core/mlx5_vport.c

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c	Wed Dec  5 13:41:06 2018	(r341555)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c	Wed Dec  5 13:41:37 2018	(r341556)
@@ -1601,9 +1601,10 @@ static char *get_dest_name(struct mlx5_flow_destinatio
 	case MLX5_FLOW_CONTEXT_DEST_TYPE_TIR:
 		snprintf(name, 20, "dest_%s_%u", "tir", dest->tir_num);
 		return name;
+	default:
+		kfree(name);
+		return NULL;
 	}
-
-	return NULL;
 }
 
 /* assumed fg is locked */

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c	Wed Dec  5 13:41:06 2018	(r341555)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c	Wed Dec  5 13:41:37 2018	(r341556)
@@ -153,6 +153,7 @@ failure:
 		bus_dmamem_free(dev->cmd.dma_tag, fwp[x].virt_addr, fwp[x].dma_map);
 	}
 	sx_xunlock(&dev->cmd.dma_sx);
+	kfree(fwp);
 	return (NULL);
 }
 

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_vport.c
==============================================================================
--- head/sys/dev/mlx5/mlx5_core/mlx5_vport.c	Wed Dec  5 13:41:06 2018	(r341555)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_vport.c	Wed Dec  5 13:41:37 2018	(r341556)
@@ -1597,8 +1597,8 @@ int mlx5_query_vport_counter(struct mlx5_core_dev *dev
 
 	err = mlx5_cmd_exec(dev, in, in_sz, out,  out_size);
 
-	kvfree(in);
 ex:
+	kvfree(in);
 	return err;
 }
 EXPORT_SYMBOL_GPL(mlx5_query_vport_counter);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812051341.wB5Dfb2E076724>