Skip to content

Commit

Permalink
don't malloc(0)
Browse files Browse the repository at this point in the history
spotted by mrg@
  • Loading branch information
hppallan committed Mar 21, 2019
1 parent 23e6703 commit 7c846cd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sys/dev/pci/radeonfb.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: radeonfb.c,v 1.101 2019/03/20 23:05:18 macallan Exp $ */
/* $NetBSD: radeonfb.c,v 1.102 2019/03/21 17:40:36 macallan Exp $ */

/*-
* Copyright (c) 2006 Itronix Inc.
Expand Down Expand Up @@ -70,7 +70,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.101 2019/03/20 23:05:18 macallan Exp $");
__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.102 2019/03/21 17:40:36 macallan Exp $");

#include <sys/param.h>
#include <sys/systm.h>
Expand Down Expand Up @@ -1401,11 +1401,13 @@ radeonfb_loadbios(struct radeonfb_softc *sc, const struct pci_attach_args *pa)
RADEON_CRTC_DISPLAY_DIS));
pci_find_rom(pa, romt, romh, romsz, PCI_ROM_CODE_TYPE_X86, &biosh,
&sc->sc_biossz);
if (sc->sc_biossz != 0) printf("found disabled BIOS\n");

foundit:
sc->sc_bios = malloc(sc->sc_biossz, M_DEVBUF, M_WAITOK);
bus_space_read_region_1(romt, biosh, 0, sc->sc_bios, sc->sc_biossz);
if (sc->sc_biossz > 0) {
sc->sc_bios = malloc(sc->sc_biossz, M_DEVBUF, M_WAITOK);
bus_space_read_region_1(romt, biosh, 0, sc->sc_bios,
sc->sc_biossz);
}

if (bios_voodoo != 0) {
radeonfb_put32(sc, RADEON_CRTC_EXT_CNTL, extc);
Expand Down

0 comments on commit 7c846cd

Please sign in to comment.