Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Aug 2016 17:40:53 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 212156] Problem with camperiphunit() interpretation of device hints
Message-ID:  <bug-212156-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=212156

            Bug ID: 212156
           Summary: Problem with camperiphunit() interpretation of device
                    hints
           Product: Base System
           Version: 10.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: mbrian@netapp.com

There's an issue with the way camperiphunit interprets device hints.
First, I discovered this because the cam(4) documentation lists the hint
name as:

hint.da.<n>.unit
when the code looks for:
hint.da.<n>.lun
(I've reported that separately).

However, the code in cam_periph.c (camperiphunit()) does:

        for (wired = 0; resource_find_dev(&i, dname, &dunit, NULL, NULL) == 0;
             wired = 0) {
                if (resource_string_value(dname, dunit, "at", &strval) == 0) {
                        if (strcmp(strval, pathbuf) != 0)
                                continue;
                        wired++;
                }
                if (resource_int_value(dname, dunit, "target", &val) == 0) {
                        if (val != target)
                                continue;
                        wired++;
                }
                if (resource_int_value(dname, dunit, "lun", &val) == 0) {
                        if (val != lun)
                                continue;
                        wired++;
                }
                if (wired != 0) {
                        unit = dunit;
                        break;
                }
        }

This works correctly if all three hints exist and match. However, if one of
the hints does not exist (since it has the wrong name), this code will still
match. Then net result is that with several device that differ only by lun
number, all will match the first set of hints and an attempt will be made
to assign duplicate da<n> unit numbers.

I suspect that if (wired != 0) should be if (wired ==3).

-- 
You are receiving this mail because:
You are the assignee for the bug.


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-212156-8>