From nobody@FreeBSD.org  Thu Jan 24 16:04:26 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id 7A716958
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 24 Jan 2013 16:04:26 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 6C7D51EB
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 24 Jan 2013 16:04:26 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r0OG4PPX027203
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 24 Jan 2013 16:04:25 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r0OG4Ph4027202;
	Thu, 24 Jan 2013 16:04:25 GMT
	(envelope-from nobody)
Message-Id: <201301241604.r0OG4Ph4027202@red.freebsd.org>
Date: Thu, 24 Jan 2013 16:04:25 GMT
From: Michael Pounov <misho@elwix.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Kernel compilation crash in bktr driver
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         175546
>Category:       kern
>Synopsis:       [bktr] [patch] Kernel compilation crash in bktr driver
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pluknet
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 24 16:10:00 UTC 2013
>Closed-Date:    Wed May 15 21:37:54 UTC 2013
>Last-Modified:  Wed May 15 21:40:00 UTC 2013
>Originator:     Michael Pounov
>Release:        FreeBSD-current
>Organization:
ELWIX
>Environment:
FreeBSD elwix.aitnet.org 10.0-CURRENT FreeBSD 10.0-CURRENT #31: Thu Jan 24 14:33:42 EET 2013     root@elwix.aitnet.org:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
When include bktr driver into kernel with this lines:

device          bktr
options         BKTR_NEW_MSP34XX_DRIVER

compilation stops due to error in msp34xx.c

kproc_create() have changed arguments of function.
>How-To-Repeat:
Include into kernel config this lines:

device          bktr
options         BKTR_NEW_MSP34XX_DRIVER

>Fix:
--- msp34xx.c	2012-11-22 11:08:13.000000000 +0200
+++ /home/fbsd_work.src/src/sys/dev/bktr/msp34xx.c	2013-01-24 17:46:17.000000000 +0200
@@ -1198,7 +1198,7 @@
 
 	/* startup control thread */
 	err = kproc_create(msp->simple ? msp3410d_thread : msp3400c_thread,
-			     bktr, &msp->kthread, (RFFDG | RFPROC), 0,
+			     bktr, &msp->kthread, (RFFDG | RFPROC), 0, "%s",
 			     msp->threaddesc);
 	if (err) {
 		printf("%s: Error returned by kproc_create: %d", bktr_name(bktr), err);


Patch attached with submission follows:

--- msp34xx.c	2012-11-22 11:08:13.000000000 +0200
+++ /home/fbsd_work.src/src/sys/dev/bktr/msp34xx.c	2013-01-24 17:46:17.000000000 +0200
@@ -1198,7 +1198,7 @@
 
 	/* startup control thread */
 	err = kproc_create(msp->simple ? msp3410d_thread : msp3400c_thread,
-			     bktr, &msp->kthread, (RFFDG | RFPROC), 0,
+			     bktr, &msp->kthread, (RFFDG | RFPROC), 0, "%s",
 			     msp->threaddesc);
 	if (err) {
 		printf("%s: Error returned by kproc_create: %d", bktr_name(bktr), err);


>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/175546: commit references a PR
Date: Tue, 30 Apr 2013 05:08:30 +0000 (UTC)

 Author: pluknet
 Date: Tue Apr 30 05:08:17 2013
 New Revision: 250088
 URL: http://svnweb.freebsd.org/changeset/base/250088
 
 Log:
   Pass a format string to kproc_create() [1] and thus fix the build with
   -DBKTR_NEW_MSP34XX_DRIVER and -Wformat-security.
   This also allows to eliminates a superfluous malloc/snprintf/free on
   intermediate buffer.
   
   PR:		kern/175546
   MFC after:	1 week
 
 Modified:
   head/sys/dev/bktr/msp34xx.c
 
 Modified: head/sys/dev/bktr/msp34xx.c
 ==============================================================================
 --- head/sys/dev/bktr/msp34xx.c	Tue Apr 30 01:15:10 2013	(r250087)
 +++ head/sys/dev/bktr/msp34xx.c	Tue Apr 30 05:08:17 2013	(r250088)
 @@ -134,7 +134,6 @@ struct msp3400c {
  
  	/* thread */
  	struct proc	    *kthread;
 -	char                *threaddesc;
  
  	int                  active,restart,rmmod;
  
 @@ -1147,12 +1146,6 @@ int msp_attach(bktr_ptr_t bktr)
  	msp->bass   = 32768;
  	msp->treble = 32768;
  	msp->input  = -1;
 -	msp->threaddesc = malloc(15 * sizeof(char), M_DEVBUF, M_NOWAIT);
 -	if (msp->threaddesc == NULL) {
 -		free(msp, M_DEVBUF);
 -                return ENOMEM;
 -	}
 -	snprintf(msp->threaddesc, 14, "%s_msp34xx_thread", bktr->bktr_xname);
  
  	for (i = 0; i < DFP_COUNT; i++)
  		msp->dfp_regs[i] = -1;
 @@ -1163,7 +1156,6 @@ int msp_attach(bktr_ptr_t bktr)
  	if (-1 != rev1)
  		rev2 = msp3400c_read(bktr, I2C_MSP3400C_DFP, 0x1f);
  	if ((-1 == rev1) || (0 == rev1 && 0 == rev2)) {
 -		free(msp->threaddesc, M_DEVBUF);
  		free(msp, M_DEVBUF);
  		bktr->msp3400c_info = NULL;
  		printf("%s: msp3400: error while reading chip version\n", bktr_name(bktr));
 @@ -1199,10 +1191,9 @@ int msp_attach(bktr_ptr_t bktr)
  	/* startup control thread */
  	err = kproc_create(msp->simple ? msp3410d_thread : msp3400c_thread,
  			     bktr, &msp->kthread, (RFFDG | RFPROC), 0,
 -			     msp->threaddesc);
 +			     "%s_msp34xx_thread", bktr->bktr_xname);
  	if (err) {
  		printf("%s: Error returned by kproc_create: %d", bktr_name(bktr), err);
 -		free(msp->threaddesc, M_DEVBUF);
  		free(msp, M_DEVBUF);
  		bktr->msp3400c_info = NULL;
  		return ENXIO;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: pluknet 
State-Changed-When: Tue Apr 30 05:14:25 UTC 2013 
State-Changed-Why:  
Thanks! A bit more intrusive change was committed though. 


Responsible-Changed-From-To: freebsd-bugs->pluknet 
Responsible-Changed-By: pluknet 
Responsible-Changed-When: Tue Apr 30 05:14:25 UTC 2013 
Responsible-Changed-Why:  
Track. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=175546 
State-Changed-From-To: patched->closed 
State-Changed-By: pluknet 
State-Changed-When: Wed May 15 21:37:25 UTC 2013 
State-Changed-Why:  
Merged to stable branches. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=175546 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/175546: commit references a PR
Date: Wed, 15 May 2013 21:37:27 +0000 (UTC)

 Author: pluknet
 Date: Wed May 15 21:37:08 2013
 New Revision: 250684
 URL: http://svnweb.freebsd.org/changeset/base/250684
 
 Log:
   MFC r250088:
     Pass a format string to kproc_create() [1] and thus fix the build with
     -DBKTR_NEW_MSP34XX_DRIVER and -Wformat-security.
   
   PR:		kern/175546
 
 Modified:
   stable/8/sys/dev/bktr/msp34xx.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/dev/   (props changed)
   stable/8/sys/dev/bktr/   (props changed)
 
 Modified: stable/8/sys/dev/bktr/msp34xx.c
 ==============================================================================
 --- stable/8/sys/dev/bktr/msp34xx.c	Wed May 15 21:35:22 2013	(r250683)
 +++ stable/8/sys/dev/bktr/msp34xx.c	Wed May 15 21:37:08 2013	(r250684)
 @@ -134,7 +134,6 @@ struct msp3400c {
  
  	/* thread */
  	struct proc	    *kthread;
 -	char                *threaddesc;
  
  	int                  active,restart,rmmod;
  
 @@ -1147,12 +1146,6 @@ int msp_attach(bktr_ptr_t bktr)
  	msp->bass   = 32768;
  	msp->treble = 32768;
  	msp->input  = -1;
 -	msp->threaddesc = malloc(15 * sizeof(char), M_DEVBUF, M_NOWAIT);
 -	if (msp->threaddesc == NULL) {
 -		free(msp, M_DEVBUF);
 -                return ENOMEM;
 -	}
 -	snprintf(msp->threaddesc, 14, "%s_msp34xx_thread", bktr->bktr_xname);
  
  	for (i = 0; i < DFP_COUNT; i++)
  		msp->dfp_regs[i] = -1;
 @@ -1163,7 +1156,6 @@ int msp_attach(bktr_ptr_t bktr)
  	if (-1 != rev1)
  		rev2 = msp3400c_read(bktr, I2C_MSP3400C_DFP, 0x1f);
  	if ((-1 == rev1) || (0 == rev1 && 0 == rev2)) {
 -		free(msp->threaddesc, M_DEVBUF);
  		free(msp, M_DEVBUF);
  		bktr->msp3400c_info = NULL;
  		printf("%s: msp3400: error while reading chip version\n", bktr_name(bktr));
 @@ -1199,10 +1191,9 @@ int msp_attach(bktr_ptr_t bktr)
  	/* startup control thread */
  	err = kproc_create(msp->simple ? msp3410d_thread : msp3400c_thread,
  			     bktr, &msp->kthread, (RFFDG | RFPROC), 0,
 -			     msp->threaddesc);
 +			     "%s_msp34xx_thread", bktr->bktr_xname);
  	if (err) {
  		printf("%s: Error returned by kproc_create: %d", bktr_name(bktr), err);
 -		free(msp->threaddesc, M_DEVBUF);
  		free(msp, M_DEVBUF);
  		bktr->msp3400c_info = NULL;
  		return ENXIO;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
