Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/iscsi Provide missing file ops. Before a simple read...



details:   https://anonhg.NetBSD.org/src/rev/13b104e9a5b7
branches:  trunk
changeset: 379557:13b104e9a5b7
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Jun 06 10:40:14 2021 +0000

description:
Provide missing file ops. Before a simple read() would panic the kernel.
No longer fail close().

diffstat:

 sys/dev/iscsi/iscsi_main.c |  20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diffs (45 lines):

diff -r 1fb612207cb1 -r 13b104e9a5b7 sys/dev/iscsi/iscsi_main.c
--- a/sys/dev/iscsi/iscsi_main.c        Sun Jun 06 10:39:10 2021 +0000
+++ b/sys/dev/iscsi/iscsi_main.c        Sun Jun 06 10:40:14 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iscsi_main.c,v 1.35 2021/04/24 23:36:56 thorpej Exp $  */
+/*     $NetBSD: iscsi_main.c,v 1.36 2021/06/06 10:40:14 mlelstv Exp $  */
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -87,8 +87,15 @@ static int iscsiclose(struct file *);
 
 static const struct fileops iscsi_fileops = {
        .fo_name = "iscsi",
+       .fo_read = fbadop_read,
+       .fo_write = fbadop_write,
        .fo_ioctl = iscsiioctl,
+       .fo_fcntl = fnullop_fcntl,
+       .fo_poll = fnullop_poll,
+       .fo_stat = fbadop_stat,
        .fo_close = iscsiclose,
+       .fo_kqfilter = fnullop_kqfilter,
+       .fo_restart = fnullop_restart
 };
 
 struct cdevsw iscsi_cdevsw = {
@@ -166,15 +173,12 @@ iscsiclose(struct file *fp)
        struct iscsi_softc *sc;
 
        sc = device_lookup_private(&iscsi_cd, d->fd_unit);
-       if (sc == NULL) {
-               DEBOUT(("%s: Cannot find private data\n",__func__));
-               return ENXIO;
+       if (sc != NULL) {
+               mutex_enter(&sc->lock);
+               TAILQ_REMOVE(&sc->fds, d, fd_link);
+               mutex_exit(&sc->lock);
        }
 
-       mutex_enter(&sc->lock);
-       TAILQ_REMOVE(&sc->fds, d, fd_link);
-       mutex_exit(&sc->lock);
-
        kmem_free(d, sizeof(*d));
        fp->f_iscsi = NULL;
 



Home | Main Index | Thread Index | Old Index