Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern devsw(9): Fix case of existing conv in devsw_attach.



details:   https://anonhg.NetBSD.org/src/rev/f26a2532c569
branches:  trunk
changeset: 369700:f26a2532c569
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Aug 28 11:17:38 2022 +0000

description:
devsw(9): Fix case of existing conv in devsw_attach.

- Fix sense of conditional: if we found a conv, i < max_devsw_convs.
- Make sure to initialize error on the way out.

PR kern/56962: Incorrect behavior of the devsw_attach function

diffstat:

 sys/kern/subr_devsw.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r af41131c61a5 -r f26a2532c569 sys/kern/subr_devsw.c
--- a/sys/kern/subr_devsw.c     Sun Aug 28 10:48:15 2022 +0000
+++ b/sys/kern/subr_devsw.c     Sun Aug 28 11:17:38 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_devsw.c,v 1.46 2022/07/09 10:30:27 riastradh Exp $        */
+/*     $NetBSD: subr_devsw.c,v 1.47 2022/08/28 11:17:38 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.46 2022/07/09 10:30:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.47 2022/08/28 11:17:38 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
@@ -194,8 +194,10 @@
         * If we already found a conv, we're done.  Otherwise, find an
         * empty slot or extend the table.
         */
-       if (i == max_devsw_convs)
+       if (i != max_devsw_convs) {
+               error = 0;
                goto out;
+       }
 
        for (i = 0; i < max_devsw_convs; i++) {
                if (devsw_conv[i].d_name == NULL)



Home | Main Index | Thread Index | Old Index