From nobody@FreeBSD.org  Sun Jul 24 13:39:23 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2062A16A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 24 Jul 2005 13:39:23 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E7BC443D4C
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 24 Jul 2005 13:39:22 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j6ODdMFT078410
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 24 Jul 2005 13:39:22 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j6ODdMp0078409;
	Sun, 24 Jul 2005 13:39:22 GMT
	(envelope-from nobody)
Message-Id: <200507241339.j6ODdMp0078409@www.freebsd.org>
Date: Sun, 24 Jul 2005 13:39:22 GMT
From: Markus Wild <fbsd-lists@dudes.ch>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] panic in fw_bus_explore due to NULL reference
X-Send-Pr-Version: www-2.3

>Number:         83999
>Category:       kern
>Synopsis:       [firewire] [patch] panic in fw_bus_explore due to NULL reference
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-firewire
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 24 13:40:23 GMT 2005
>Closed-Date:    Sun Dec 04 02:32:46 GMT 2005
>Last-Modified:  Sun Dec 04 02:32:46 GMT 2005
>Originator:     Markus Wild
>Release:        current amd64
>Organization:
>Environment:
FreeBSD amd64.dudes.ch 7.0-CURRENT FreeBSD 7.0-CURRENT #29: Sat Jul 16 18:30:24 CEST 2005     mw@amd64.dudes.ch:/usr/obj/usr/src/sys/AMD64  amd64

>Description:
Machine panics at

fw_bus_explore+0x3f: testb $0x40,0x(%rax)

with %rax being NULL. 

The problem is the line (1339):
       if (!fw_find_self_id(fc, fc->ongonode)->p0.link_active) {

fw_find_self_id() can return 0 if it doesn't find the node. This  is
not taken into account with the above test.

>How-To-Repeat:
On this machine it was sufficient to load the firewire module to
trigger the panic. A canopus ADV module was plugged into the 
firewire port. 

>Fix:
diff -u -r1.80 firewire.c
--- firewire.c  6 Jan 2005 01:42:41 -0000       1.80
+++ firewire.c  24 Jul 2005 13:37:09 -0000
@@ -1324,6 +1324,7 @@
        uint32_t addr;
        struct fw_xfer *xfer;
        struct fw_pkt *fp;
+       union fw_self_id *fwsid;
 
        if(fc->status != FWBUSEXPLORE)
                return;
@@ -1336,7 +1337,8 @@
 
        /* check link */
        /* XXX we need to check phy_id first */
-       if (!fw_find_self_id(fc, fc->ongonode)->p0.link_active) {
+       fwsid = fw_find_self_id(fc, fc->ongonode);
+       if (!fwsid || !fwsid->p0.link_active) {
                if (firewire_debug)
                        printf("node%d: link down\n", fc->ongonode);
                fc->ongonode++;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-firewire 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Oct 25 02:37:39 GMT 2005 
Responsible-Changed-Why:  
Over to maintainer(s). 

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

From: "Cai, Quanqing" <caiquanqing@gmail.com>
To: simokawa@freebsd.org, bug-followup@FreeBSD.org, fbsd-lists@dudes.ch, 
	freebsd-current@freebsd.org
Cc:  
Subject: Re: kern/83999 : [firewire] [patch] panic in fw_bus_explore due to NULL reference
Date: Thu, 24 Nov 2005 19:23:56 -0800

 Can somebody please have a look at this and apply the patch? However,
 I can't re-produce this bug, but the fix does not hurt anything. I
 made the changement on my two machines according the patch, and
 everything looks and works good. One of machine is 7.0-CURRENT,
 another one is 6-STABLE.
 
 BR
 Cai, Quanqing
State-Changed-From-To: open->feedback 
State-Changed-By: simokawa 
State-Changed-When: Fri Nov 25 14:30:03 GMT 2005 
State-Changed-Why:  
Committed, thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=83999 
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Sun Dec 4 02:31:55 GMT 2005 
State-Changed-Why:  
Fix was committed Nov. 25th. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=83999 
>Unformatted:
