lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <08c88cad-b4cf-948a-e990-390617503ffd@users.sourceforge.net>
Date:   Tue, 14 Nov 2017 21:38:28 +0100
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     alsa-devel@...a-project.org, Bhumika Goyal <bhumirks@...il.com>,
        Jaroslav Kysela <perex@...ex.cz>,
        Takashi Iwai <tiwai@...e.com>,
        Takashi Sakamoto <o-takashi@...amocchi.jp>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: [PATCH 3/3] ALSA: es1938: Use common error handling code in
 snd_es1938_create()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Tue, 14 Nov 2017 21:25:55 +0100

Add jump targets so that a bit of exception handling can be better reused
at the end of this function.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 sound/pci/es1938.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index b19e611345d1..2b4dd1297bbc 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1606,14 +1606,14 @@ static int snd_es1938_create(struct snd_card *card,
 	    dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
 		dev_err(card->dev,
 			"architecture does not support 24bit PCI busmaster DMA\n");
-		pci_disable_device(pci);
-                return -ENXIO;
+		err = -ENXIO;
+		goto disable_device;
         }
 
 	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
 	if (chip == NULL) {
-		pci_disable_device(pci);
-		return -ENOMEM;
+		err = -ENOMEM;
+		goto disable_device;
 	}
 	spin_lock_init(&chip->reg_lock);
 	spin_lock_init(&chip->mixer_lock);
@@ -1623,8 +1623,7 @@ static int snd_es1938_create(struct snd_card *card,
 	err = pci_request_regions(pci, "ESS Solo-1");
 	if (err < 0) {
 		kfree(chip);
-		pci_disable_device(pci);
-		return err;
+		goto disable_device;
 	}
 	chip->io_port = pci_resource_start(pci, 0);
 	chip->sb_port = pci_resource_start(pci, 1);
@@ -1634,8 +1633,8 @@ static int snd_es1938_create(struct snd_card *card,
 	if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED,
 			KBUILD_MODNAME, chip)) {
 		dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
-		snd_es1938_free(chip);
-		return -EBUSY;
+		err = -EBUSY;
+		goto free_sound_chip;
 	}
 	chip->irq = pci->irq;
 	dev_dbg(card->dev,
@@ -1647,13 +1646,19 @@ static int snd_es1938_create(struct snd_card *card,
 	snd_es1938_chip_init(chip);
 
 	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
-	if (err < 0) {
-		snd_es1938_free(chip);
-		return err;
-	}
+	if (err < 0)
+		goto free_sound_chip;
 
 	*rchip = chip;
 	return 0;
+
+disable_device:
+	pci_disable_device(pci);
+	return err;
+
+free_sound_chip:
+	snd_es1938_free(chip);
+	return err;
 }
 
 /* --------------------------------------------------------------------
-- 
2.15.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ