ALSA: usx2y: Don't call free_pages_exact() with NULL address

[ Upstream commit cae0cf651adccee2c3f376e78f30fbd788d0829f ]

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>
This commit is contained in:
Takashi Iwai 2021-05-17 15:15:43 +02:00 committed by Greg Kroah-Hartman
parent 7dff52b311
commit 88262229b7
1 changed files with 5 additions and 2 deletions

View File

@ -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;
}