From 3b96cf0548080dc298fcb380ddef155545c53a1a Mon Sep 17 00:00:00 2001 From: Achal Verma Date: Thu, 15 Apr 2021 09:53:26 +0530 Subject: tegra-ahci: Fix potential null ptr dereference. Condition to check ptr being non-null before use. This fix coverity issue: 9820675 Bug 200741055 Change-Id: I815d79fa899437c0bf24dc96505470b23b7990c1 Signed-off-by: Achal Verma Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2515237 Reviewed-by: svcacv Reviewed-by: Dmitry Pervushin Reviewed-by: Rahul Jain (SW-TEGRA) GVS: Gerrit_Virtual_Submit (cherry picked from commit 940245b31a1569cb4d1227b86a51b2f366714135) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2574549 Reviewed-by: svc-mobile-coverity Reviewed-by: Phoenix Jung Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/ata/tegra/ahci_tegra.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/ata/tegra/ahci_tegra.c b/drivers/ata/tegra/ahci_tegra.c index aa9cdde9e..cd2602a59 100644 --- a/drivers/ata/tegra/ahci_tegra.c +++ b/drivers/ata/tegra/ahci_tegra.c @@ -1,7 +1,7 @@ /* * drivers/ata/ahci_tegra.c * - * Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2021, NVIDIA CORPORATION. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -569,9 +569,11 @@ static void tegra_ahci_unbind(struct work_struct *work) struct ata_port *ap = host->ports[i]; unsigned long flags; + if (!ap) + continue; spin_lock_irqsave(ap->lock, flags); - if (ap && ((ap->pflags & ATA_PFLAG_LOADING) || - (ap->pflags & ATA_PFLAG_INITIALIZING))) { + if ((ap->pflags & ATA_PFLAG_LOADING) || + (ap->pflags & ATA_PFLAG_INITIALIZING)) { INIT_DELAYED_WORK(&tegra->work, tegra_ahci_unbind); schedule_delayed_work(&tegra->work, msecs_to_jiffies(1000)); spin_unlock_irqrestore(ap->lock, flags); -- cgit v1.2.2