From: anton Date: Thu, 30 Dec 2021 14:25:39 +0000 (+0000) Subject: Use a distinct variable while iterating the list of existing devices. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7945134bbda7ff60550100e843ec5dd4d08c0867;p=openbsd Use a distinct variable while iterating the list of existing devices. ok mvs@ Reported-by: syzbot+e2d1df67f742a5a47938@syzkaller.appspotmail.com Reported-by: syzbot+72298724beda82ec8e7f@syzkaller.appspotmail.com --- diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index b4f8904aa30..00e6bd937fd 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.112 2021/12/30 00:49:41 mvs Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.113 2021/12/30 14:25:39 anton Exp $ */ /* * Copyright (c) 2010 Claudio Jeker @@ -1006,13 +1006,14 @@ pppacattach(int n) int pppacopen(dev_t dev, int flags, int mode, struct proc *p) { - struct pppac_softc *sc; + struct pppac_softc *sc, *tmp; struct ifnet *ifp; struct pipex_session *session; sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO); - LIST_FOREACH(sc, &pppac_devs, sc_entry) { - if (sc->sc_dev == dev) { + sc->sc_dev = dev; + LIST_FOREACH(tmp, &pppac_devs, sc_entry) { + if (tmp->sc_dev == dev) { free(sc, M_DEVBUF, sizeof(*sc)); return (EBUSY); } @@ -1025,8 +1026,6 @@ pppacopen(dev_t dev, int flags, int mode, struct proc *p) session->ownersc = sc; sc->sc_multicast_session = session; - sc->sc_dev = dev; - mtx_init(&sc->sc_rsel_mtx, IPL_SOFTNET); mtx_init(&sc->sc_wsel_mtx, IPL_SOFTNET); mq_init(&sc->sc_mq, IFQ_MAXLEN, IPL_SOFTNET);