NetBSD Problem Report #54662

From sc.dying@gmail.com  Wed Oct 30 06:33:35 2019
Return-Path: <sc.dying@gmail.com>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 53D1A7A1FC
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 30 Oct 2019 06:33:35 +0000 (UTC)
Message-Id: <aec45fd3-3370-43d7-4747-34668406fea4@gmail.com>
Date: Wed, 30 Oct 2019 06:33:28 +0000
From: sc.dying@gmail.com
Reply-To:
To: gnats-bugs@NetBSD.org
Subject: uaudio sometimes not recognized

>Number:         54662
>Category:       kern
>Synopsis:       uaudio sometimes not recognized
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    isaki
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 30 06:35:00 +0000 2019
>Closed-Date:    Mon Nov 04 05:56:36 +0000 2019
>Last-Modified:  Tue Nov 19 13:00:02 +0000 2019
>Originator:     sc.dying@gmail.com
>Release:        NetBSD/evbarm 9.99.17
>Organization:
>Environment:
System: NetBSD  9.99.17 NetBSD 9.99.17 (GENERIC) #0: Sun Oct 27 15:43:46 UTC 2019  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/evbarm/compile/GENERIC evbarm
Architecture: earmv7hf
Machine: evbarm
Boardtype: Raspberry Pi 3 Model B Rev 1.2
>Description:

 The kernel sometimes fails to attach uaudio(4).

[   5.9522585] audio0: audio_hw_probe failed, error = 6
[   5.9522585] audio0: disabled

At attaching, uaudio(4) kmem_alloc's sc->sc_formats[] in uaudio_identify_as(),
but does not memset(0) them.
One of uninitialized value sc_formats[0].priority is 0xaaaaaaaa in my case,
so audio_hw_probe_fmt() fails with ENXIO.

>How-To-Repeat:


>Fix:

memset(0), or use kmem_zalloc to allocate sc->sc_formats, please.

--- src/sys/dev/usb/uaudio.c.orig	2019-06-06 14:28:12.919115132 +0000
+++ src/sys/dev/usb/uaudio.c	2019-10-29 14:27:39.826567634 +0000
@@ -1795,7 +1795,7 @@ uaudio_identify_as(struct uaudio_softc *
 	}

 	/* build audio_format array */
-	sc->sc_formats = kmem_alloc(sizeof(struct audio_format) * sc->sc_nalts,
+	sc->sc_formats = kmem_zalloc(sizeof(struct audio_format) * sc->sc_nalts,
 	    KM_SLEEP);
 	sc->sc_nformats = sc->sc_nalts;
 	for (i = 0; i < sc->sc_nalts; i++) {

>Release-Note:

>Audit-Trail:
From: "Tetsuya Isaki" <isaki@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54662 CVS commit: src/sys/dev/usb
Date: Mon, 4 Nov 2019 05:46:40 +0000

 Module Name:	src
 Committed By:	isaki
 Date:		Mon Nov  4 05:46:39 UTC 2019

 Modified Files:
 	src/sys/dev/usb: uaudio.c

 Log Message:
 Use kmem_zalloc() instead of kmem_alloc() to initialize structure.
 struct audio_format added a member since isaki-audio2.
 Fix PR kern/54662 "uaudio sometimes not recognized".


 To generate a diff of this commit:
 cvs rdiff -u -r1.161 -r1.162 src/sys/dev/usb/uaudio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Responsible-Changed-From-To: kern-bug-people->isaki
Responsible-Changed-By: isaki@NetBSD.org
Responsible-Changed-When: Mon, 04 Nov 2019 05:56:36 +0000
Responsible-Changed-Why:


State-Changed-From-To: open->closed
State-Changed-By: isaki@NetBSD.org
State-Changed-When: Mon, 04 Nov 2019 05:56:36 +0000
State-Changed-Why:
Committed.  Thank you for reporting!


From: sc dying <sc.dying@gmail.com>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: PR/54662 CVS commit: src/sys/dev/usb
Date: Mon, 4 Nov 2019 12:51:43 +0000

 Thank you for fixing the problem.

 On Mon, Nov 4, 2019 at 5:50 AM Tetsuya Isaki <isaki@netbsd.org> wrote:
 >
 > The following reply was made to PR kern/54662; it has been noted by GNATS.
 >
 > From: "Tetsuya Isaki" <isaki@netbsd.org>
 > To: gnats-bugs@gnats.NetBSD.org
 > Cc:
 > Subject: PR/54662 CVS commit: src/sys/dev/usb
 > Date: Mon, 4 Nov 2019 05:46:40 +0000
 >
 >  Module Name:   src
 >  Committed By:  isaki
 >  Date:          Mon Nov  4 05:46:39 UTC 2019
 >
 >  Modified Files:
 >         src/sys/dev/usb: uaudio.c
 >
 >  Log Message:
 >  Use kmem_zalloc() instead of kmem_alloc() to initialize structure.
 >  struct audio_format added a member since isaki-audio2.
 >  Fix PR kern/54662 "uaudio sometimes not recognized".
 >
 >
 >  To generate a diff of this commit:
 >  cvs rdiff -u -r1.161 -r1.162 src/sys/dev/usb/uaudio.c
 >
 >  Please note that diffs are not public domain; they are subject to the
 >  copyright notices on the relevant files.
 >

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54662 CVS commit: [netbsd-9] src/sys/dev/usb
Date: Tue, 19 Nov 2019 12:56:48 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Tue Nov 19 12:56:48 UTC 2019

 Modified Files:
 	src/sys/dev/usb [netbsd-9]: uaudio.c

 Log Message:
 Pull up following revision(s) (requested by isaki in ticket #447):

 	sys/dev/usb/uaudio.c: revision 1.162

 Use kmem_zalloc() instead of kmem_alloc() to initialize structure.
 struct audio_format added a member since isaki-audio2.

 Fix PR kern/54662 "uaudio sometimes not recognized".


 To generate a diff of this commit:
 cvs rdiff -u -r1.161 -r1.161.2.1 src/sys/dev/usb/uaudio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.