lib: configfs: Fix the memory allocation for the array of format descriptors calloc() expects the first parameter to be the number of elements and the second to be the size of each element in bytes. The arguments passed to calloc() are reversed. Fix it by swapping the arguments. Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
diff --git a/lib/configfs.c b/lib/configfs.c index 0c17ca1..21a78c3 100644 --- a/lib/configfs.c +++ b/lib/configfs.c
@@ -660,7 +660,7 @@ } format->num_frames = n_entries; - format->frames = calloc(sizeof *format->frames, format->num_frames); + format->frames = calloc(format->num_frames, sizeof *format->frames); if (!format->frames) return -ENOMEM; @@ -744,7 +744,7 @@ } cfg->num_formats = n_entries; - cfg->formats = calloc(sizeof *cfg->formats, cfg->num_formats); + cfg->formats = calloc(cfg->num_formats, sizeof *cfg->formats); if (!cfg->formats) return -ENOMEM;