Reduce a piece of malloc/free.

Signed-off-by: Leo Ma <leoma@credosemi.com>