• B
    resource: Fix find_next_iomem_res() iteration issue · 2fc0e5c6
    Bjorn Helgaas 提交于
    [ Upstream commit 010a93bf97c72f43aac664d0a685942f83d1a103 ]
    
    Previously find_next_iomem_res() used "*res" as both an input parameter for
    the range to search and the type of resource to search for, and an output
    parameter for the resource we found, which makes the interface confusing.
    
    The current callers use find_next_iomem_res() incorrectly because they
    allocate a single struct resource and use it for repeated calls to
    find_next_iomem_res().  When find_next_iomem_res() returns a resource, it
    overwrites the start, end, flags, and desc members of the struct.  If we
    call find_next_iomem_res() again, we must update or restore these fields.
    The previous code restored res.start and res.end, but not res.flags or
    res.desc.
    
    Since the callers did not restore res.flags, if they searched for flags
    IORESOURCE_MEM | IORESOURCE_BUSY and found a resource with flags
    IORESOURCE_MEM | IORESOURCE_BUSY | IORESOURCE_SYSRAM, the next search would
    incorrectly skip resources unless they were also marked as
    IORESOURCE_SYSRAM.
    
    Fix this by restructuring the interface so it takes explicit "start, end,
    flags" parameters and uses "*res" only as an output parameter.
    
    Based on a patch by Lianbo Jiang <lijiang@redhat.com>.
    
     [ bp: While at it:
       - make comments kernel-doc style.
       -
    
    Originally-by: http://lore.kernel.org/lkml/20180921073211.20097-2-lijiang@redhat.comSigned-off-by: NBjorn Helgaas <bhelgaas@google.com>
    Signed-off-by: NBorislav Petkov <bp@suse.de>
    CC: Andrew Morton <akpm@linux-foundation.org>
    CC: Brijesh Singh <brijesh.singh@amd.com>
    CC: Dan Williams <dan.j.williams@intel.com>
    CC: H. Peter Anvin <hpa@zytor.com>
    CC: Lianbo Jiang <lijiang@redhat.com>
    CC: Takashi Iwai <tiwai@suse.de>
    CC: Thomas Gleixner <tglx@linutronix.de>
    CC: Tom Lendacky <thomas.lendacky@amd.com>
    CC: Vivek Goyal <vgoyal@redhat.com>
    CC: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
    CC: bhe@redhat.com
    CC: dan.j.williams@intel.com
    CC: dyoung@redhat.com
    CC: kexec@lists.infradead.org
    CC: mingo@redhat.com
    CC: x86-ml <x86@kernel.org>
    Link: http://lkml.kernel.org/r/153805812916.1157.177580438135143788.stgit@bhelgaas-glaptop.roam.corp.google.comSigned-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    2fc0e5c6
resource.c 39.5 KB