From 7ccd55044110312c15d7e87a9a9cc3c72597b917 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Wed, 26 Feb 2014 00:17:24 +0400 Subject: [PATCH] LU-4629 obdclass: fix use after release Pointer 'type->typ_name' checked for NULL at line 195 will be passed to function and may be dereferenced there by passing argument 1 to function 'lprocfs_try_remove_proc_entry' at line 246. Signed-off-by: Dmitry Eremin Change-Id: I697ffab97a5bd1ab55339722d87a3dfca5c1e173 Reviewed-on: http://review.whamcloud.com/9388 Tested-by: Jenkins Reviewed-by: John L. Hammond Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/obdclass/genops.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 89c315e..bf8b6ce 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -234,19 +234,21 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, RETURN (0); failed: +#ifdef LPROCFS + if (type->typ_name != NULL) { +#ifndef HAVE_ONLY_PROCFS_SEQ + lprocfs_try_remove_proc_entry(type->typ_name, proc_lustre_root); +#else + remove_proc_subtree(type->typ_name, proc_lustre_root); +#endif + } +#endif if (type->typ_name != NULL) OBD_FREE(type->typ_name, strlen(name) + 1); if (type->typ_md_ops != NULL) OBD_FREE_PTR(type->typ_md_ops); if (type->typ_dt_ops != NULL) OBD_FREE_PTR(type->typ_dt_ops); -#ifdef LPROCFS -#ifndef HAVE_ONLY_PROCFS_SEQ - lprocfs_try_remove_proc_entry(type->typ_name, proc_lustre_root); -#else - remove_proc_subtree(type->typ_name, proc_lustre_root); -#endif -#endif OBD_FREE(type, sizeof(*type)); RETURN(rc); } -- 1.8.3.1