diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index a9a72574b34ab..684761e86d4fc 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -716,6 +716,7 @@ error: kfree(wbuf); error_1: kfree(wr_msg); + bus->defer_msg.msg = NULL; return ret; } @@ -839,9 +840,10 @@ static int do_bank_switch(struct sdw_stream_runtime *stream) error: list_for_each_entry(m_rt, &stream->master_list, stream_node) { bus = m_rt->bus; - - kfree(bus->defer_msg.msg->buf); - kfree(bus->defer_msg.msg); + if (bus->defer_msg.msg) { + kfree(bus->defer_msg.msg->buf); + kfree(bus->defer_msg.msg); + } } msg_unlock: