Skip to content

Commit

Permalink
ALSA: usx2y: Don't call free_pages_exact() with NULL address
Browse files Browse the repository at this point in the history
[ Upstream commit cae0cf6 ]

Unlike some other functions, we can't pass NULL pointer to
free_pages_exact().  Add a proper NULL check for avoiding possible
Oops.

Link: https://lore.kernel.org/r/20210517131545.27252-10-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
tiwai authored and gregkh committed Jul 20, 2021
1 parent 6c9a4c6 commit 82e5ee7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sound/usb/usx2y/usb_stream.c
Expand Up @@ -142,8 +142,11 @@ void usb_stream_free(struct usb_stream_kernel *sk)
if (!s)
return;

free_pages_exact(sk->write_page, s->write_size);
sk->write_page = NULL;
if (sk->write_page) {
free_pages_exact(sk->write_page, s->write_size);
sk->write_page = NULL;
}

free_pages_exact(s, s->read_size);
sk->s = NULL;
}
Expand Down

0 comments on commit 82e5ee7

Please sign in to comment.