Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libata: remove superfluous NULL pointer checks

host->ports[] always contain pointers to valid port structures since
a "dummy port" structure is used in case if there is no physical port.

This patch takes care of two entries from Dan's list:

drivers/ata/sata_sil.c +535 sil_interrupt(13) warning: variable derefenced before check 'ap'
drivers/ata/sata_mv.c +2517 mv_unexpected_intr(6) warning: variable derefenced before check 'ap'

and of another needless NULL pointer check in pata_octeon_cf.c.

Reported-by: Dan Carpenter <error27@gmail.com>
Cc: corbet@lwn.net
Cc: eteo@redhat.com
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

authored by

Bartlomiej Zolnierkiewicz and committed by
Jeff Garzik
c9abde12 705d2014

+4 -3
+2 -1
drivers/ata/pata_octeon_cf.c
··· 653 653 654 654 ap = host->ports[i]; 655 655 ocd = ap->dev->platform_data; 656 - if (!ap || (ap->flags & ATA_FLAG_DISABLED)) 656 + 657 + if (ap->flags & ATA_FLAG_DISABLED) 657 658 continue; 658 659 659 660 ocd = ap->dev->platform_data;
+1 -1
drivers/ata/sata_mv.c
··· 2514 2514 char *when = "idle"; 2515 2515 2516 2516 ata_ehi_clear_desc(ehi); 2517 - if (!ap || (ap->flags & ATA_FLAG_DISABLED)) { 2517 + if (ap->flags & ATA_FLAG_DISABLED) { 2518 2518 when = "disabled"; 2519 2519 } else if (edma_was_enabled) { 2520 2520 when = "EDMA enabled";
+1 -1
drivers/ata/sata_sil.c
··· 532 532 struct ata_port *ap = host->ports[i]; 533 533 u32 bmdma2 = readl(mmio_base + sil_port[ap->port_no].bmdma2); 534 534 535 - if (unlikely(!ap || ap->flags & ATA_FLAG_DISABLED)) 535 + if (unlikely(ap->flags & ATA_FLAG_DISABLED)) 536 536 continue; 537 537 538 538 /* turn off SATA_IRQ if not supported */