From nobody Fri Nov 11 17:57:44 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N85yc3LP5z4dTYx; Fri, 11 Nov 2022 17:57:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N85yc2QtSz3Qm5; Fri, 11 Nov 2022 17:57:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668189464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Bneat/5Q9mJPPtRzG/kHlWyc/bdqlvxs7uhtx2MFfPY=; b=fZm/cBf9MBJaIp2ymiYwKC8kEpGEZ0ft4f62o9rkRgWZrEVVD3Mo5cavKeDh9E0VqxuW1s eO/rb1wgkhltDfRjDNyhyEvZvnJNxqujV5CzKIUDRzh5Mia56gh97Ee8xU2MhpU9l06hAl ra1ztTjdm4ZCwqJKJzSU9NP0zNMIcvFkQk9DSlo7iSwQnDdhwBea/j43129/ROfAlFnSyu g5vVQvFJ+Q/objjzTk57DsxnghWHWeUC9PKgFSeQIE9RpMBRnIzSmlB/eu+OLb01pw2BFd sX8eHjwe5OHUbTwvMybMLEmtNYUZqTlzSLnWdqKxHIWn7TaiR9vLkTg7rjyKKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668189464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Bneat/5Q9mJPPtRzG/kHlWyc/bdqlvxs7uhtx2MFfPY=; b=SRVtmpYl6bUiCAdR1UYoZsoVEZ3Uw+6AbCnpebHGQZ4ZXHswzwaDxoAVcf69fHjR/XFxFV i5aBvVSVX+YlC+PaJRG0jILV7JyRmhlreIR4HI/5Mg+DfWNeIKGheNdQS9tffaY14/ZAoL WnBIaItPP6ZcC4yhOSv4pIFgTWjd4XFykP42J8UIRux3KFD2DH/g86kl4MuwhiorJP9k3D GMyftmTSqfDzq4V3aJZTaPy57ubaLYccibpovqnaEwpbOwILh6UdbH9X4RSSqBdiM1kCHf 2rGgJpzt4ATa2m8/34mgjhZNAUgImV2cFHJLMesA791H5kOlHfA95f8QJJAn0w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668189464; a=rsa-sha256; cv=none; b=L2UY2p33OtJSlKpABaKa3tn5gBKGys5elXd8ub4nprtnvlAHm09Z+lQp5+pTIGv7vZcY6v IFIg7rcpP+wBJ6ltp87G5Eb6FshcVDcwL5FKjm+b+GEJ6yGsZ+I1PJBa7TsiDS7W8FPHrI K8PvsLcT7DZzIW5MHAKOVe+cpMkdqardSV/EGN5NEVJxNa70TJk9lX1t6Xm92UgdsngrSx gSn9iqEgR8ZhPp/fhgA/3+hx0ugD210wsA6CM2tUn5g7cNQ3k0S6B8fYUGa0+3nacI1TEW VHPeJmN4UcyjL51w4Lfy2mTK2G4axvQq1RTjLgG8Jx9lLK2d52al16mc7uefhA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N85yc1Tz0zrhb; Fri, 11 Nov 2022 17:57:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2ABHvi0w044790; Fri, 11 Nov 2022 17:57:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2ABHvi6M044789; Fri, 11 Nov 2022 17:57:44 GMT (envelope-from git) Date: Fri, 11 Nov 2022 17:57:44 GMT Message-Id: <202211111757.2ABHvi6M044789@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: 1ad6b2b1daa8 - main - linuxkpi: Add `krealloc_array()` List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1ad6b2b1daa8937b2e1ced43802adba5734ba92b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=1ad6b2b1daa8937b2e1ced43802adba5734ba92b commit 1ad6b2b1daa8937b2e1ced43802adba5734ba92b Author: Jean-Sébastien Pédron AuthorDate: 2022-11-11 17:37:34 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2022-11-11 17:37:34 +0000 linuxkpi: Add `krealloc_array()` In FreeBSD, this is a wrapper on top of `realloc()`. V2: Check if `n * size` would overflow and return `NULL` if that's the case. Suggested by hselasky@ and emaste@. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D36959 --- sys/compat/linuxkpi/common/include/linux/slab.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h index 16b5afcea693..8f1cb433c36b 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -178,6 +178,16 @@ krealloc(void *ptr, size_t size, gfp_t flags) return (realloc(ptr, size, M_KMALLOC, linux_check_m_flags(flags))); } +static inline void * +krealloc_array(void *ptr, size_t n, size_t size, gfp_t flags) +{ + if (WOULD_OVERFLOW(n, size)) { + return NULL; + } + + return (realloc(ptr, n * size, M_KMALLOC, linux_check_m_flags(flags))); +} + extern void linux_kfree_async(void *); static inline void