lkml.org 
[lkml]   [2018]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 46/77] PCI: endpoint: Fix find_first_zero_bit() usage
    Date
    4.14-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Niklas Cassel <niklas.cassel@axis.com>


    [ Upstream commit 35ad61921f495ee14915d185de79478c1737b4da ]

    find_first_zero_bit()'s parameter 'size' is defined in bits,
    not in bytes.

    Calling find_first_zero_bit() with the wrong size unit
    will lead to insidious bugs.

    Fix this by calling find_first_zero_bit() with size BITS_PER_LONG,
    rather than sizeof() and add missing find_first_zero_bit() return
    handling.

    Fixes: d74679911610 ("PCI: endpoint: Introduce configfs entry for configuring EP functions")
    Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
    Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/pci/endpoint/pci-ep-cfs.c | 5 ++++-
    1 file changed, 4 insertions(+), 1 deletion(-)

    --- a/drivers/pci/endpoint/pci-ep-cfs.c
    +++ b/drivers/pci/endpoint/pci-ep-cfs.c
    @@ -109,7 +109,10 @@ static int pci_epc_epf_link(struct confi
    goto err_add_epf;

    func_no = find_first_zero_bit(&epc_group->function_num_map,
    - sizeof(epc_group->function_num_map));
    + BITS_PER_LONG);
    + if (func_no >= BITS_PER_LONG)
    + return -EINVAL;
    +
    set_bit(func_no, &epc_group->function_num_map);
    epf->func_no = func_no;


    \
     
     \ /
      Last update: 2018-03-23 12:45    [W:4.313 / U:0.068 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site