Patch "OPP: Fix potential null ptr dereference in dev_pm_opp_get_required_pstate()" has been added to the 6.5-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

    OPP: Fix potential null ptr dereference in dev_pm_opp_get_required_pstate()

to the 6.5-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:
     opp-fix-potential-null-ptr-dereference-in-dev_pm_opp.patch
and it can be found in the queue-6.5 subdirectory.

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



commit e453e4cefb2380397fb560d24f68e86237b1ee50
Author: Manivannan Sadhasivam <mani@xxxxxxxxxx>
Date:   Fri Jul 21 18:16:33 2023 +0530

    OPP: Fix potential null ptr dereference in dev_pm_opp_get_required_pstate()
    
    [ Upstream commit 7ddd8deb1c3c0363a7e14fafb5df26e2089a69a5 ]
    
    "opp" pointer is dereferenced before the IS_ERR_OR_NULL() check. Fix it by
    removing the dereference to cache opp_table and dereference it directly
    where opp_table is used.
    
    This fixes the following smatch warning:
    
    drivers/opp/core.c:232 dev_pm_opp_get_required_pstate() warn: variable
    dereferenced before IS_ERR check 'opp' (see line 230)
    
    Fixes: 84cb7ff35fcf ("OPP: pstate is only valid for genpd OPP tables")
    Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
    Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 3f46e499d615f..98633ccd170a3 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -227,20 +227,18 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_level);
 unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp,
 					    unsigned int index)
 {
-	struct opp_table *opp_table = opp->opp_table;
-
 	if (IS_ERR_OR_NULL(opp) || !opp->available ||
-	    index >= opp_table->required_opp_count) {
+	    index >= opp->opp_table->required_opp_count) {
 		pr_err("%s: Invalid parameters\n", __func__);
 		return 0;
 	}
 
 	/* required-opps not fully initialized yet */
-	if (lazy_linking_pending(opp_table))
+	if (lazy_linking_pending(opp->opp_table))
 		return 0;
 
 	/* The required OPP table must belong to a genpd */
-	if (unlikely(!opp_table->required_opp_tables[index]->is_genpd)) {
+	if (unlikely(!opp->opp_table->required_opp_tables[index]->is_genpd)) {
 		pr_err("%s: Performance state is only valid for genpds.\n", __func__);
 		return 0;
 	}



[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