lkml.org 
[lkml]   [2019]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 4.19 237/276] scsi: lpfc: avoid uninitialized variable warning
    Hi!

    > [ Upstream commit faf5a744f4f8d76e7c03912b5cd381ac8045f6ec ]
    >
    > clang -Wuninitialized incorrectly sees a variable being used without
    > initialization:
    >
    > drivers/scsi/lpfc/lpfc_nvme.c:2102:37: error: variable 'localport' is uninitialized when used here
    > [-Werror,-Wuninitialized]
    > lport = (struct lpfc_nvme_lport *)localport->private;
    > ^~~~~~~~~
    > drivers/scsi/lpfc/lpfc_nvme.c:2059:38: note: initialize the variable 'localport' to silence this warning
    > struct nvme_fc_local_port *localport;
    > ^
    > = NULL
    > 1 error generated.
    >
    > This is clearly in dead code, as the condition leading up to it is always
    > false when CONFIG_NVME_FC is disabled, and the variable is always
    > initialized when nvme_fc_register_localport() got called successfully.
    >
    > Change the preprocessor conditional to the equivalent C construct, which
    > makes the code more readable and gets rid of the warning.

    Unfortunately, this missed "else" branch where the code was freeing
    the memory with kfree(cstat)... so this introduces a memory leak.

    Best regards,
    Pavel

    > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    > Acked-by: James Smart <james.smart@broadcom.com>
    > Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    > Signed-off-by: Sasha Levin <sashal@kernel.org>


    --
    (english) http://www.livejournal.com/~pavelmachek
    (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
    [unhandled content-type:application/pgp-signature]
    \
     
     \ /
      Last update: 2019-06-06 14:54    [W:2.992 / U:0.276 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site