Patch "firmware: stratix10-svc: fix a missing check on list iterator" has been added to the 5.10-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

    firmware: stratix10-svc: fix a missing check on list iterator

to the 5.10-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:
     firmware-stratix10-svc-fix-a-missing-check-on-list-i.patch
and it can be found in the queue-5.10 subdirectory.

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



commit d573be90df507516102b76777d7fdd9892035f53
Author: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx>
Date:   Thu Apr 14 11:56:09 2022 +0800

    firmware: stratix10-svc: fix a missing check on list iterator
    
    [ Upstream commit 5a0793ac66ac0e254d292f129a4d6c526f9f2aff ]
    
    The bug is here:
            pmem->vaddr = NULL;
    
    The list iterator 'pmem' will point to a bogus position containing
    HEAD if the list is empty or no element is found. This case must
    be checked before any use of the iterator, otherwise it will
    lead to a invalid memory access.
    
    To fix this bug, just gen_pool_free/set NULL/list_del() and return
    when found, otherwise list_del HEAD and return;
    
    Fixes: 7ca5ce896524f ("firmware: add Intel Stratix10 service layer driver")
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20220414035609.2239-1-xiam0nd.tong@xxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index 53c7e3f8cfde..7dd0ac1a0cfc 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -941,17 +941,17 @@ EXPORT_SYMBOL_GPL(stratix10_svc_allocate_memory);
 void stratix10_svc_free_memory(struct stratix10_svc_chan *chan, void *kaddr)
 {
 	struct stratix10_svc_data_mem *pmem;
-	size_t size = 0;
 
 	list_for_each_entry(pmem, &svc_data_mem, node)
 		if (pmem->vaddr == kaddr) {
-			size = pmem->size;
-			break;
+			gen_pool_free(chan->ctrl->genpool,
+				       (unsigned long)kaddr, pmem->size);
+			pmem->vaddr = NULL;
+			list_del(&pmem->node);
+			return;
 		}
 
-	gen_pool_free(chan->ctrl->genpool, (unsigned long)kaddr, size);
-	pmem->vaddr = NULL;
-	list_del(&pmem->node);
+	list_del(&svc_data_mem);
 }
 EXPORT_SYMBOL_GPL(stratix10_svc_free_memory);
 



[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