Skip to contentSkip to conversation

ALSA: firewire-lib: fix error codes for allocation failure

PATCH Applied Dan Carpenter 3 participants 3 messages Jun 5, 2021 – Jun 6, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: firewire-lib: fix error codes for allocation failure

Return -ENOMEM if kcalloc() fails. Currently the code returns success.

Fixes f9e5ecdfc2c2 ("ALSA: firewire-lib: add replay target to cache sequence of packet")
Fixes 6f24bb8a157c ("ALSA: firewire-lib: pool sequence of packet in IT context independently")
---
 sound/firewire/amdtp-stream.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
sound/firewire/amdtp-stream.c +6 -2
index 945597ffacc2..b37cec3cc579 100644
@@ -1625,8 +1625,10 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed,
 			s->ctx_data.tx.cache.tail = 0;
 			s->ctx_data.tx.cache.descs = kcalloc(s->ctx_data.tx.cache.size,
 						sizeof(*s->ctx_data.tx.cache.descs), GFP_KERNEL);
-			if (!s->ctx_data.tx.cache.descs)
+			if (!s->ctx_data.tx.cache.descs) {
+				err = -ENOMEM;
 				goto err_context;
+			}
 		}
 	} else {
 		static const struct {
@@ -1643,8 +1645,10 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed,
 		};
 
 		s->ctx_data.rx.seq.descs = kcalloc(queue_size, sizeof(*s->ctx_data.rx.seq.descs), GFP_KERNEL);
-		if (!s->ctx_data.rx.seq.descs)
+		if (!s->ctx_data.rx.seq.descs) {
+			err = -ENOMEM;
 			goto err_context;
+		}
 		s->ctx_data.rx.seq.size = queue_size;
 		s->ctx_data.rx.seq.tail = 0;
 		s->ctx_data.rx.seq.head = 0;
Signature · 1 line
2.30.2
maintainer Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 39 lines · Dan Carpenter

Return -ENOMEM if kcalloc() fails. Currently the code returns success.

Fixes f9e5ecdfc2c2 ("ALSA: firewire-lib: add replay target to cache sequence of packet")
Fixes 6f24bb8a157c ("ALSA: firewire-lib: pool sequence of packet in IT context independently")
---
 sound/firewire/amdtp-stream.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
sound/firewire/amdtp-stream.c +6 -2
index 945597ffacc2..b37cec3cc579 100644
@@ -1625,8 +1625,10 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed,
 			s->ctx_data.tx.cache.tail = 0;
 			s->ctx_data.tx.cache.descs = kcalloc(s->ctx_data.tx.cache.size,
 						sizeof(*s->ctx_data.tx.cache.descs), GFP_KERNEL);
-			if (!s->ctx_data.tx.cache.descs)
+			if (!s->ctx_data.tx.cache.descs) {
+				err = -ENOMEM;
 				goto err_context;
+			}
 		}
 	} else {
 		static const struct {
@@ -1643,8 +1645,10 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed,
 		};
 
 		s->ctx_data.rx.seq.descs = kcalloc(queue_size, sizeof(*s->ctx_data.rx.seq.descs), GFP_KERNEL);
-		if (!s->ctx_data.rx.seq.descs)
+		if (!s->ctx_data.rx.seq.descs) {
+			err = -ENOMEM;
 			goto err_context;
+		}
 		s->ctx_data.rx.seq.size = queue_size;
 		s->ctx_data.rx.seq.tail = 0;
 		s->ctx_data.rx.seq.head = 0;
Signature · 1 line
2.30.2

Indeed... Nice to catch it.

Thanks

Takashi Sakamoto.

Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

Return -ENOMEM if kcalloc() fails. Currently the code returns success.

Fixes f9e5ecdfc2c2 ("ALSA: firewire-lib: add replay target to cache sequence of packet")
Fixes 6f24bb8a157c ("ALSA: firewire-lib: pool sequence of packet in IT context independently")

Thanks, applied.

Takashi