aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/sound/midi
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2018-01-13 22:30:30 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2018-01-13 22:30:30 +0000
commit26c1d774b55c4db79bca772941883244986e6f44 (patch)
tree0d4a99e9eba470c0808a66d7d3f857c9f36446fa /sys/dev/sound/midi
parenta019e26c0f76f5fd5c401cd87554ef2d5efc36ca (diff)
downloadsrc-26c1d774b55c4db79bca772941883244986e6f44.tar.gz
src-26c1d774b55c4db79bca772941883244986e6f44.zip
dev: make some use of mallocarray(9).
Focus on code where we are doing multiplications within malloc(9). None of these is likely to overflow, however the change is still useful as some static checkers can benefit from the allocation attributes we use for mallocarray. This initial sweep only covers malloc(9) calls with M_NOWAIT. No good reason but I started doing the changes before r327796 and at that time it was convenient to make sure the sorrounding code could handle NULL values.
Notes
Notes: svn path=/head/; revision=327949
Diffstat (limited to 'sys/dev/sound/midi')
-rw-r--r--sys/dev/sound/midi/midi.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c
index 325106200320..70e5bd1a9295 100644
--- a/sys/dev/sound/midi/midi.c
+++ b/sys/dev/sound/midi/midi.c
@@ -340,14 +340,15 @@ midi_init(kobj_class_t cls, int unit, int channel, void *cookie)
mtx_lock(&m->qlock);
if (inqsize)
- buf = malloc(sizeof(MIDI_TYPE) * inqsize, M_MIDI, M_NOWAIT);
+ buf = mallocarray(inqsize, sizeof(MIDI_TYPE), M_MIDI, M_NOWAIT);
else
buf = NULL;
MIDIQ_INIT(m->inq, buf, inqsize);
if (outqsize)
- buf = malloc(sizeof(MIDI_TYPE) * outqsize, M_MIDI, M_NOWAIT);
+ buf = mallocarray(outqsize, sizeof(MIDI_TYPE), M_MIDI,
+ M_NOWAIT);
else
buf = NULL;
m->hiwat = outqsize / 2;