@@ -1388,14 +1388,15 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
1388
1388
if (ret < 0 ) {
1389
1389
dev_err (scomp -> dev , "failed to parse component pin tokens for %s\n" ,
1390
1390
w -> name );
1391
- return ret ;
1391
+ goto widget_free ;
1392
1392
}
1393
1393
1394
1394
if (swidget -> num_sink_pins > SOF_WIDGET_MAX_NUM_PINS ||
1395
1395
swidget -> num_source_pins > SOF_WIDGET_MAX_NUM_PINS ) {
1396
1396
dev_err (scomp -> dev , "invalid pins for %s: [sink: %d, src: %d]\n" ,
1397
1397
swidget -> widget -> name , swidget -> num_sink_pins , swidget -> num_source_pins );
1398
- return - EINVAL ;
1398
+ ret = - EINVAL ;
1399
+ goto widget_free ;
1399
1400
}
1400
1401
1401
1402
if (swidget -> num_sink_pins > 1 ) {
@@ -1404,7 +1405,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
1404
1405
if (ret < 0 ) {
1405
1406
dev_err (scomp -> dev , "failed to parse sink pin binding for %s\n" ,
1406
1407
w -> name );
1407
- return ret ;
1408
+ goto widget_free ;
1408
1409
}
1409
1410
}
1410
1411
@@ -1414,7 +1415,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
1414
1415
if (ret < 0 ) {
1415
1416
dev_err (scomp -> dev , "failed to parse source pin binding for %s\n" ,
1416
1417
w -> name );
1417
- return ret ;
1418
+ goto widget_free ;
1418
1419
}
1419
1420
}
1420
1421
@@ -1436,9 +1437,8 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
1436
1437
case snd_soc_dapm_dai_out :
1437
1438
dai = kzalloc (sizeof (* dai ), GFP_KERNEL );
1438
1439
if (!dai ) {
1439
- kfree (swidget );
1440
- return - ENOMEM ;
1441
-
1440
+ ret = - ENOMEM ;
1441
+ goto widget_free ;
1442
1442
}
1443
1443
1444
1444
ret = sof_widget_parse_tokens (scomp , swidget , tw , token_list , token_list_size );
@@ -1496,8 +1496,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
1496
1496
tw -> shift , swidget -> id , tw -> name ,
1497
1497
strnlen (tw -> sname , SNDRV_CTL_ELEM_ID_NAME_MAXLEN ) > 0
1498
1498
? tw -> sname : "none" );
1499
- kfree (swidget );
1500
- return ret ;
1499
+ goto widget_free ;
1501
1500
}
1502
1501
1503
1502
if (sof_debug_check_flag (SOF_DBG_DISABLE_MULTICORE )) {
@@ -1518,10 +1517,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
1518
1517
if (ret ) {
1519
1518
dev_err (scomp -> dev , "widget event binding failed for %s\n" ,
1520
1519
swidget -> widget -> name );
1521
- kfree (swidget -> private );
1522
- kfree (swidget -> tuples );
1523
- kfree (swidget );
1524
- return ret ;
1520
+ goto free ;
1525
1521
}
1526
1522
}
1527
1523
}
@@ -1532,10 +1528,8 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
1532
1528
1533
1529
spipe = kzalloc (sizeof (* spipe ), GFP_KERNEL );
1534
1530
if (!spipe ) {
1535
- kfree (swidget -> private );
1536
- kfree (swidget -> tuples );
1537
- kfree (swidget );
1538
- return - ENOMEM ;
1531
+ ret = - ENOMEM ;
1532
+ goto free ;
1539
1533
}
1540
1534
1541
1535
spipe -> pipe_widget = swidget ;
@@ -1546,6 +1540,12 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
1546
1540
w -> dobj .private = swidget ;
1547
1541
list_add (& swidget -> list , & sdev -> widget_list );
1548
1542
return ret ;
1543
+ free :
1544
+ kfree (swidget -> private );
1545
+ kfree (swidget -> tuples );
1546
+ widget_free :
1547
+ kfree (swidget );
1548
+ return ret ;
1549
1549
}
1550
1550
1551
1551
static int sof_route_unload (struct snd_soc_component * scomp ,
0 commit comments