From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F198C433DB for ; Fri, 26 Feb 2021 01:21:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 91E5564EFA for ; Fri, 26 Feb 2021 01:21:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 91E5564EFA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 29A8E6B00E7; Thu, 25 Feb 2021 20:21:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 270A06B00E8; Thu, 25 Feb 2021 20:21:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1870F6B00E9; Thu, 25 Feb 2021 20:21:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id F16A36B00E7 for ; Thu, 25 Feb 2021 20:21:19 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C2CB3824C453 for ; Fri, 26 Feb 2021 01:21:19 +0000 (UTC) X-FDA: 77858665878.18.9AB93DB Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf11.hostedemail.com (Postfix) with ESMTP id 2B4822000386 for ; Fri, 26 Feb 2021 01:21:09 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 4209B64F21; Fri, 26 Feb 2021 01:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1614302478; bh=E6Onz8b7748teRxbJX1mitClQ/q5sF49slCl0Tk/krs=; h=Date:From:To:Subject:In-Reply-To:From; b=DvfeOHnFSk5DhOuRLigtZdFtIf5p1lt4OV0RR/fl8rLfayXRxKLFHlDZ9a36OD4rv zB4zGi322pO86MoKFel/TmSc7kqsy7co8JeAY7tc1AKOlu82EVGcYgd4CIRfHPnNwY /+ccGy9zLCWuBMeKoWU4ZNzX/b2lZQ37dU8tY3zA= Date: Thu, 25 Feb 2021 17:21:17 -0800 From: Andrew Morton To: akpm@linux-foundation.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, sjhuang@iluvatar.ai, torvalds@linux-foundation.org Subject: [patch 092/118] lib/genalloc.c: change return type to unsigned long for bitmap_set_ll Message-ID: <20210226012117.QK0oTujwY%akpm@linux-foundation.org> In-Reply-To: <20210225171452.713967e96554bb6a53e44a19@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2B4822000386 X-Stat-Signature: gxguyijpuncx5983op5jn18b6tfa9qgs Received-SPF: none (linux-foundation.org>: No applicable sender policy available) receiver=imf11; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614302469-939778 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Huang Shijie Subject: lib/genalloc.c: change return type to unsigned long for bitmap_set_ll Just as bitmap_clear_ll(), change return type to unsigned long for bitmap_set_ll to avoid the possible overflow in future. Link: https://lkml.kernel.org/r/20210105031644.2771-1-sjhuang@iluvatar.ai Signed-off-by: Huang Shijie Signed-off-by: Andrew Morton --- lib/genalloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/lib/genalloc.c~lib-genalloc-change-return-type-to-unsigned-long-for-bitmap_set_ll +++ a/lib/genalloc.c @@ -81,7 +81,8 @@ static int clear_bits_ll(unsigned long * * users set the same bit, one user will return remain bits, otherwise * return 0. */ -static int bitmap_set_ll(unsigned long *map, unsigned long start, unsigned long nr) +static unsigned long +bitmap_set_ll(unsigned long *map, unsigned long start, unsigned long nr) { unsigned long *p = map + BIT_WORD(start); const unsigned long size = start + nr; _