Fri May 1 01:34:58 2020 UTC ()
Zero rndsource before using it.

XXX pullup


(riastradh)
diff -r1.61 -r1.62 src/sys/dev/ic/pckbc.c

cvs diff -r1.61 -r1.62 src/sys/dev/ic/pckbc.c (expand / switch to unified diff)

--- src/sys/dev/ic/pckbc.c 2019/11/10 21:16:35 1.61
+++ src/sys/dev/ic/pckbc.c 2020/05/01 01:34:57 1.62
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pckbc.c,v 1.61 2019/11/10 21:16:35 chs Exp $ */ 1/* $NetBSD: pckbc.c,v 1.62 2020/05/01 01:34:57 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2004 Ben Harris. 4 * Copyright (c) 2004 Ben Harris.
5 * Copyright (c) 1998 5 * Copyright (c) 1998
6 * Matthias Drochner. All rights reserved. 6 * Matthias Drochner. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.61 2019/11/10 21:16:35 chs Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: pckbc.c,v 1.62 2020/05/01 01:34:57 riastradh Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34#include <sys/callout.h> 34#include <sys/callout.h>
35#include <sys/kernel.h> 35#include <sys/kernel.h>
36#include <sys/proc.h> 36#include <sys/proc.h>
37#include <sys/device.h> 37#include <sys/device.h>
38#include <sys/malloc.h> 38#include <sys/malloc.h>
39#include <sys/errno.h> 39#include <sys/errno.h>
40#include <sys/queue.h> 40#include <sys/queue.h>
41 41
42#include <sys/bus.h> 42#include <sys/bus.h>
43 43
@@ -252,29 +252,32 @@ pckbc_attach_slot(struct pckbc_softc *sc @@ -252,29 +252,32 @@ pckbc_attach_slot(struct pckbc_softc *sc
252 M_DEVBUF, M_WAITOK); 252 M_DEVBUF, M_WAITOK);
253 t->t_slotdata[slot] = sdata; 253 t->t_slotdata[slot] = sdata;
254 pckbc_init_slotdata(t->t_slotdata[slot]); 254 pckbc_init_slotdata(t->t_slotdata[slot]);
255 alloced++; 255 alloced++;
256 } 256 }
257 257
258 child = pckbport_attach_slot(sc->sc_dv, t->t_pt, slot); 258 child = pckbport_attach_slot(sc->sc_dv, t->t_pt, slot);
259 259
260 if (child == NULL && alloced) { 260 if (child == NULL && alloced) {
261 free(t->t_slotdata[slot], M_DEVBUF); 261 free(t->t_slotdata[slot], M_DEVBUF);
262 t->t_slotdata[slot] = NULL; 262 t->t_slotdata[slot] = NULL;
263 } 263 }
264 264
265 if (child != NULL && t->t_slotdata[slot] != NULL) 265 if (child != NULL && t->t_slotdata[slot] != NULL) {
 266 memset(&t->t_slotdata[slot]->rnd_source, 0,
 267 sizeof(t->t_slotdata[slot]->rnd_source));
266 rnd_attach_source(&t->t_slotdata[slot]->rnd_source, 268 rnd_attach_source(&t->t_slotdata[slot]->rnd_source,
267 device_xname(child), RND_TYPE_TTY, RND_FLAG_DEFAULT); 269 device_xname(child), RND_TYPE_TTY, RND_FLAG_DEFAULT);
 270 }
268 271
269 return child != NULL; 272 return child != NULL;
270} 273}
271 274
272void 275void
273pckbc_attach(struct pckbc_softc *sc) 276pckbc_attach(struct pckbc_softc *sc)
274{ 277{
275 struct pckbc_internal *t; 278 struct pckbc_internal *t;
276 bus_space_tag_t iot; 279 bus_space_tag_t iot;
277 bus_space_handle_t ioh_d, ioh_c; 280 bus_space_handle_t ioh_d, ioh_c;
278 int res; 281 int res;
279 u_char cmdbits = 0; 282 u_char cmdbits = 0;
280 283