lkml.org 
[lkml]   [2020]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4/8] pinctrl: use krealloc_array()
    Date
    From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

    Use the helper that checks for overflows internally instead of manually
    calculating the size of the new array.

    Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
    ---
    drivers/pinctrl/pinctrl-utils.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/drivers/pinctrl/pinctrl-utils.c b/drivers/pinctrl/pinctrl-utils.c
    index f2bcbf62c03d..93df0d4c0a24 100644
    --- a/drivers/pinctrl/pinctrl-utils.c
    +++ b/drivers/pinctrl/pinctrl-utils.c
    @@ -39,7 +39,7 @@ int pinctrl_utils_reserve_map(struct pinctrl_dev *pctldev,
    if (old_num >= new_num)
    return 0;

    - new_map = krealloc(*map, sizeof(*new_map) * new_num, GFP_KERNEL);
    + new_map = krealloc_array(*map, new_num, sizeof(*new_map), GFP_KERNEL);
    if (!new_map) {
    dev_err(pctldev->dev, "krealloc(map) failed\n");
    return -ENOMEM;
    --
    2.29.1
    \
     
     \ /
      Last update: 2020-10-27 13:19    [W:4.667 / U:0.172 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site