Skip to content

Commit e4aa85c

Browse files
committed
Merge branch 'microchip-fixes'
Shang XiaoJing says: ==================== net: microchip: Fix potential null-ptr-deref due to create_singlethread_workqueue() There are some functions call create_singlethread_workqueue() without checking ret value, and the NULL workqueue_struct pointer may causes null-ptr-deref. Will be fixed by this patch. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 4e0c19f + 639f5d0 commit e4aa85c

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,9 @@ int lan966x_stats_init(struct lan966x *lan966x)
716716
snprintf(queue_name, sizeof(queue_name), "%s-stats",
717717
dev_name(lan966x->dev));
718718
lan966x->stats_queue = create_singlethread_workqueue(queue_name);
719+
if (!lan966x->stats_queue)
720+
return -ENOMEM;
721+
719722
INIT_DELAYED_WORK(&lan966x->stats_work, lan966x_check_stats_work);
720723
queue_delayed_work(lan966x->stats_queue, &lan966x->stats_work,
721724
LAN966X_STATS_CHECK_DELAY);

drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,9 @@ int sparx_stats_init(struct sparx5 *sparx5)
12531253
snprintf(queue_name, sizeof(queue_name), "%s-stats",
12541254
dev_name(sparx5->dev));
12551255
sparx5->stats_queue = create_singlethread_workqueue(queue_name);
1256+
if (!sparx5->stats_queue)
1257+
return -ENOMEM;
1258+
12561259
INIT_DELAYED_WORK(&sparx5->stats_work, sparx5_check_stats_work);
12571260
queue_delayed_work(sparx5->stats_queue, &sparx5->stats_work,
12581261
SPX5_STATS_CHECK_DELAY);

drivers/net/ethernet/microchip/sparx5/sparx5_main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,9 @@ static int sparx5_start(struct sparx5 *sparx5)
659659
snprintf(queue_name, sizeof(queue_name), "%s-mact",
660660
dev_name(sparx5->dev));
661661
sparx5->mact_queue = create_singlethread_workqueue(queue_name);
662+
if (!sparx5->mact_queue)
663+
return -ENOMEM;
664+
662665
INIT_DELAYED_WORK(&sparx5->mact_work, sparx5_mact_pull_work);
663666
queue_delayed_work(sparx5->mact_queue, &sparx5->mact_work,
664667
SPX5_MACT_PULL_DELAY);

0 commit comments

Comments
 (0)