Subject: Re: kern/36673 (dubious code is sysmon_envsys)
To: None <xtraeme@NetBSD.org, gnats-admin@netbsd.org,>
From: Juan RP <juan@xtrarom.org>
List: netbsd-bugs
Date: 07/25/2007 12:40:05
The following reply was made to PR kern/36673; it has been noted by GNATS.

From: Juan RP <juan@xtrarom.org>
To: gnats-bugs@NetBSD.org
Cc: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
Subject: Re: kern/36673 (dubious code is sysmon_envsys)
Date: Wed, 25 Jul 2007 14:36:48 +0200

 On Wed, 25 Jul 2007 11:45:04 +0000 (UTC)
 yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:
 
 >  can you provide a diff with -p?
 
 Sure, here it is: (I didn't know about -p, it's very useful :-)
 
 Index: sysmon_envsys.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/sysmon/sysmon_envsys.c,v
 retrieving revision 1.43
 diff -b -u -p -r1.43 sysmon_envsys.c
 --- sysmon_envsys.c	23 Jul 2007 17:51:16 -0000	1.43
 +++ sysmon_envsys.c	25 Jul 2007 12:34:15 -0000
 @@ -483,7 +483,6 @@ sysmon_envsys_register(struct sysmon_env
  	mutex_enter(&sme_list_mtx);
  	LIST_FOREACH(lsme, &sysmon_envsys_list, sme_list) {
  	       if (strcmp(lsme->sme_name, sme->sme_name) == 0) {
 -		       mutex_exit(&sme_list_mtx);
  		       error = EEXIST;
  		       goto out;
  	       }
 @@ -496,16 +495,14 @@ sysmon_envsys_register(struct sysmon_env
  	sme->sme_fsensor = sysmon_envsys_next_sensor_index;
  	sysmon_envsys_next_sensor_index += sme->sme_nsensors;
  #endif
 -	mutex_exit(&sme_list_mtx);
  	error = sysmon_envsys_createplist(sme);
  	if (!error) {
 -		mutex_enter(&sme_list_mtx);
  		LIST_INSERT_HEAD(&sysmon_envsys_list, sme, sme_list);
  		sme_uniqsensors = 0;
 -		mutex_exit(&sme_list_mtx);
  	}
  
  out:
 +	mutex_exit(&sme_list_mtx);
  	return error;
  }
  
 @@ -626,6 +623,9 @@ sysmon_envsys_createplist(struct sysmon_
  
  	nsens = error = 0;
  
 +	KASSERT(mutex_owned(&sme_list_mtx));
 +	mutex_exit(&sme_list_mtx);
 +
  	/* create the sysmon envsys device array. */
  	array = prop_array_create();
  	if (array == NULL)
 @@ -688,6 +688,7 @@ sysmon_envsys_createplist(struct sysmon_
  
  
  	prop_object_release(array);
 +	mutex_enter(&sme_list_mtx);
  	return error;
  }
  
 
 -- 
 Juan Romero Pardines	- The NetBSD Project
 http://plog.xtrarom.org	- NetBSD/pkgsrc news in Spanish