Skip to content

Commit 5ec0c87

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: stream: use consistent pattern for freeing buffers
The code should free the message buffer used for data, the message structure used for control and assign the latter to NULL. The last part is missing for multi-link cases, and the order is inconsistent for single-link cases. Link: thesofproject#4056 Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Signed-off-by: Bard Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 3bd3bc2 commit 5ec0c87

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/soundwire/stream.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@ static int sdw_bank_switch(struct sdw_bus *bus, int m_rt_count)
723723
}
724724

725725
if (!multi_link) {
726-
kfree(wr_msg);
727726
kfree(wbuf);
727+
kfree(wr_msg);
728728
bus->defer_msg.msg = NULL;
729729
bus->params.curr_bank = !bus->params.curr_bank;
730730
bus->params.next_bank = !bus->params.next_bank;
@@ -769,6 +769,7 @@ static int sdw_ml_sync_bank_switch(struct sdw_bus *bus)
769769
if (bus->defer_msg.msg) {
770770
kfree(bus->defer_msg.msg->buf);
771771
kfree(bus->defer_msg.msg);
772+
bus->defer_msg.msg = NULL;
772773
}
773774

774775
return 0;
@@ -867,6 +868,7 @@ static int do_bank_switch(struct sdw_stream_runtime *stream)
867868
if (bus->defer_msg.msg) {
868869
kfree(bus->defer_msg.msg->buf);
869870
kfree(bus->defer_msg.msg);
871+
bus->defer_msg.msg = NULL;
870872
}
871873
}
872874

0 commit comments

Comments
 (0)