Re: [RFC PATCH] ALSA: pci: add PreSonus Quantum PCI driver

Markus Elfring <[email protected]>
Newsgroups org.kernel.vger.linux-sound,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
…
> +++ b/sound/pci/quantum/quantum_dma.c
> @@ -0,0 +1,853 @@
…
> +static int quantum_build_page_table(struct quantum_chip *chip,
> +				    struct quantum_page_table *pt,
> +				    const struct quantum_stream *stream,
> +				    struct snd_pcm_substream *substream,
> +				    size_t audio_size,
> +				    u32 addr_per_segment)
> +{
…
+	num_segments = (num_pages + addr_per_segment - 1) / addr_per_segment;
+
+	pt->num_entries = num_pages;
+	pt->num_segments = num_segments;
+	pt->addr_per_segment = addr_per_segment;
+	pt->size = num_segments * pt_stride;
+	pt->pages = kcalloc(num_segments, sizeof(*pt->pages), GFP_KERNEL);
+	if (!pt->pages)
+		return -ENOMEM;
…

Can it be nicer to perform any additional variable assignments only after
a successful memory allocation?

Regards,
Markus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.