Patch "net: lan966x: Fix potential null-ptr-deref in lan966x_stats_init()" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: lan966x: Fix potential null-ptr-deref in lan966x_stats_init()

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-lan966x-fix-potential-null-ptr-deref-in-lan966x_.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 543af0efd315ca1a711260280e62cae0cb18fd06
Author: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
Date:   Mon Nov 14 21:38:52 2022 +0800

    net: lan966x: Fix potential null-ptr-deref in lan966x_stats_init()
    
    [ Upstream commit ba86af3733aece88dbcee0dfebf7e2dcfefb2be4 ]
    
    lan966x_stats_init() calls create_singlethread_workqueue() and not
    checked the ret value, which may return NULL. And a null-ptr-deref may
    happen:
    
    lan966x_stats_init()
        create_singlethread_workqueue() # failed, lan966x->stats_queue is NULL
        queue_delayed_work()
            queue_delayed_work_on()
                __queue_delayed_work()  # warning here, but continue
                    __queue_work()      # access wq->flags, null-ptr-deref
    
    Check the ret value and return -ENOMEM if it is NULL.
    
    Fixes: 12c2d0a5b8e2 ("net: lan966x: add ethtool configuration and statistics")
    Signed-off-by: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
    Reviewed-by: Horatiu Vultur <horatiu.vultur@xxxxxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c b/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c
index fea42542be28..06811c60d598 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c
@@ -716,6 +716,9 @@ int lan966x_stats_init(struct lan966x *lan966x)
 	snprintf(queue_name, sizeof(queue_name), "%s-stats",
 		 dev_name(lan966x->dev));
 	lan966x->stats_queue = create_singlethread_workqueue(queue_name);
+	if (!lan966x->stats_queue)
+		return -ENOMEM;
+
 	INIT_DELAYED_WORK(&lan966x->stats_work, lan966x_check_stats_work);
 	queue_delayed_work(lan966x->stats_queue, &lan966x->stats_work,
 			   LAN966X_STATS_CHECK_DELAY);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux