ALSA: usx2y: Don't call free_pages_exact() with NULL address
authorTakashi Iwai <tiwai@suse.de>
Mon, 17 May 2021 13:15:43 +0000 (15:15 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 17 May 2021 14:05:20 +0000 (16:05 +0200)
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>
sound/usb/usx2y/usb_stream.c

index 820647331aba7b9b83250f037dbd987ec9a4be6d..9d0e44793896f6c1d6128921a8bb6a0eaf039e9d 100644 (file)
@@ -143,8 +143,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;
 }