From nobody Thu Apr 9 09:27:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A9C9C433FE for ; Fri, 4 Nov 2022 04:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbiKDEDo (ORCPT ); Fri, 4 Nov 2022 00:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230074AbiKDEDj (ORCPT ); Fri, 4 Nov 2022 00:03:39 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F2CB1EC53 for ; Thu, 3 Nov 2022 21:03:37 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N3RjD2w4bzpWCT; Fri, 4 Nov 2022 12:00:00 +0800 (CST) Received: from huawei.com (10.67.174.53) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 4 Nov 2022 12:03:34 +0800 From: Liao Chang To: , , , CC: , , , Subject: [PATCH] checkpatch: Add check for array allocator family argument order Date: Fri, 4 Nov 2022 12:00:20 +0800 Message-ID: <20221104040020.16389-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.53] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" These array allocator family are sometimes misused with the first and second arguments switchted. Same issue with calloc, kvcalloc, kvmalloc_array etc. Bleat if sizeof is the first argument. Link: https://lkml.org/lkml/2022/11/3/668 Signed-off-by: Liao Chang Acked-by: Joe Perches --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1e5e66ae5a52..a9a9dc277cff 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -7128,7 +7128,7 @@ sub process { } =20 # check for alloc argument mismatch - if ($line =3D~ /\b((?:devm_)?(?:kcalloc|kmalloc_array))\s*\(\s*sizeof\b/= ) { + if ($line =3D~ /\b((?:devm_)?((?:k|kv)?(calloc|malloc_array)(?:_node)?))= \s*\(\s*sizeof\b/) { WARN("ALLOC_ARRAY_ARGS", "$1 uses number as first arg, sizeof is generally wrong\n" . $here= curr); } --=20 2.17.1