]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ata: fixes kernel crash while tracing ata_eh_link_autopsy event
authorRameshwar Prasad Sahu <rsahu@apm.com>
Thu, 2 Nov 2017 11:01:07 +0000 (16:31 +0530)
committerTejun Heo <tj@kernel.org>
Fri, 3 Nov 2017 13:23:06 +0000 (06:23 -0700)
When tracing ata link error event, the kernel crashes when the disk is
removed due to NULL pointer access by trace_ata_eh_link_autopsy API.
This occurs as the dev is NULL when the disk disappeared. This patch
fixes this crash by calling trace_ata_eh_link_autopsy only if "dev"
is not NULL.

v2 changes:
 Removed direct passing "link" pointer instead of "dev" in trace API.

Signed-off-by: Rameshwar Prasad Sahu <rsahu@apm.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Fixes: 255c03d15a29 ("libata: Add tracepoints")
Cc: stable@vger.kernel.org # v4.1+
drivers/ata/libata-eh.c

index e070fe8267ff41fcc34971848eace307ac2d37d2..6d45bfa6d6116300533780c69ad58db8aeabf3a4 100644 (file)
@@ -2264,8 +2264,8 @@ static void ata_eh_link_autopsy(struct ata_link *link)
                if (dev->flags & ATA_DFLAG_DUBIOUS_XFER)
                        eflags |= ATA_EFLAG_DUBIOUS_XFER;
                ehc->i.action |= ata_eh_speed_down(dev, eflags, all_err_mask);
+               trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask);
        }
-       trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask);
        DPRINTK("EXIT\n");
 }