[PATCH -next] ALSA: nm256: Fix error return code in snd_nm256_create()

From: Yang Yingliang
Date: Tue Jul 20 2021 - 10:13:51 EST


If pci_request_regions() fails, it should return error
code in snd_nm256_create().

Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
sound/pci/nm256/nm256.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index a54b9b26a0c2..c9c178504959 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1478,7 +1478,8 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci)
chip->buffer_addr = pci_resource_start(pci, 0);
chip->cport_addr = pci_resource_start(pci, 1);

- if (pci_request_regions(pci, card->driver))
+ err = pci_request_regions(pci, card->driver);
+ if (err < 0)
return err;

/* Init the memory port info. */
--
2.25.1