Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp505870lqs; Thu, 13 Jun 2024 17:54:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUrEbKZzr6rCDuUTNYyrmcVMxkUX6Hy+4lEdJZECymdKeZsuB7LRe9hLKsbRBHlBMYEPQJAJAfEu7uV8qUroNETRVWk/SF6G3uTEZSPNw== X-Google-Smtp-Source: AGHT+IFAWm+3WOMYVvt1pUSWX3Ykhp09Whs7mI2eJx88YWsZ7rqjzyupxjQM5fJs++0//gdExIww X-Received: by 2002:a17:90b:350d:b0:2c2:a240:77c9 with SMTP id 98e67ed59e1d1-2c4db44bcf9mr1399140a91.28.1718326499410; Thu, 13 Jun 2024 17:54:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718326499; cv=pass; d=google.com; s=arc-20160816; b=a/tfhquC0iuXBWStd4oqvVxJTazGGTjnDV6rkzbXE9g5z7LoKlbaRLxBHobky4iQgM my9SWTPK3UkMyMi5kf5GH1ZGhkT6fMePHz1XJkNxJOLV4KSsHxleqxl2OIjcJikN/XgT OtjZzACgM7hffQ8PMECic75gap+M1DwwJ1puKLDN/E2/xiilqaq11XXARfd7DGgR+PJg 2E1rOwvJBjT3fRxubhfgQdTeiJH5pkQvLOjiLK7fDMHu5fi4sVIMBWqi2aXAVVJEKVwn MQl2BUyq6vgvNj9dW5WUdUMz2qtfqBI+S8ZOOyf/JLgkFEU8rMKy+XCclB0W88xa1LHB y4Bw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:references:cc:to:from:subject; bh=T+aaucDrwdUGETMcWrvchK/Y+QzpBY3tW5HF307aJ78=; fh=ns8cs0aBzfNVzyRDSYqlRmuqTdbl/8ItlDvkuuv6xRo=; b=u/ixMiNRm5EgY5Jn0eL7idmzR+nQHAlUwD3LrUAXNkMpnGvOZgzwPZS+KdApvns/rB QmlbFFJU3Od/mOqBVXgJoq0arbP/MSdZb3J2ht+qS8P4zBtWDkZ6jHl9Y95dUgWeARTD BJjBgZWXSW6Z64lQ+06VuPxmtAsLbF/LqJMNdoD000dy5yqX8xzU+J7bVw2eLYom2l9P 9f1+EUUZj4IVFneX7sECC/nWoVe3hNcm7MB0QQaRRRgMKF5nWgi59UbT3Xc6wNfBo6tn 26O1D52emoEXe8NI0WvKk+lCg9fKDhoWzNfsRndnKeExusx9M2RIMliJpp9Dm27El8zf BSRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-214157-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4a75f3f1dsi4662873a91.67.2024.06.13.17.54.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 17:54:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214157-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-214157-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0BDF7283E9D for ; Fri, 14 Jun 2024 00:54:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D606F4409; Fri, 14 Jun 2024 00:54:52 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41CAC1C27; Fri, 14 Jun 2024 00:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718326492; cv=none; b=RCQkzV0H3G8cm1vRWkyatTS1fSvul+mk5c2PD6riU0xqX6no6TEVDFcJBkXusSWXa+A1QHJpNmSxkfsr6vC1/8JtPI0JOSAyfStIbXilhC49ylgLQLiHhSGpnh3cnYmemDU7Le3ZPHGOCvpSiwSzT0LU91+1dwzg4nnMwh9cVWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718326492; c=relaxed/simple; bh=vqYf6YTMrYPXIZv+rpZeQD4CeKk3G+SZAYDkZ+fh1Gk=; h=Subject:From:To:CC:References:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=X6qcq4WZ9cxlJoBVJF3efZspNaMnj4odrEI9bb+7uBDXw1nPzIAQXlJaqNm4DhrNiY/ptxskVVKK6XVczex54KzAcev38gKuQdnL4MWtSUp1UEGFIBXcTNXxwkngAJaQi+fCGRGb/yh/cv117NhBoYAhrj48XYam6HNsv/sSrCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4W0ggb3zMLz1X3Rk; Fri, 14 Jun 2024 08:50:51 +0800 (CST) Received: from dggpemf500002.china.huawei.com (unknown [7.185.36.57]) by mail.maildlp.com (Postfix) with ESMTPS id DC30B1402E2; Fri, 14 Jun 2024 08:54:40 +0800 (CST) Received: from [10.174.178.247] (10.174.178.247) by dggpemf500002.china.huawei.com (7.185.36.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 14 Jun 2024 08:54:40 +0800 Subject: Re: [PATCH v1 1/1] ACPI/IORT: Switch to use kmemdup_array() From: Hanjun Guo To: Andy Shevchenko , , , CC: Lorenzo Pieralisi , Sudeep Holla , "Rafael J. Wysocki" , Len Brown , Catalin Marinas References: <20240606165005.3031490-1-andriy.shevchenko@linux.intel.com> <3a1e0ffe-db11-d18f-db33-881df7d9b18d@huawei.com> Message-ID: <2edd3b72-24a4-8b19-8738-cc82dc4fae6c@huawei.com> Date: Fri, 14 Jun 2024 08:54:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <3a1e0ffe-db11-d18f-db33-881df7d9b18d@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemf500002.china.huawei.com (7.185.36.57) +Cc Catalin On 2024/6/11 18:42, Hanjun Guo wrote: > On 2024/6/7 0:50, Andy Shevchenko wrote: >> Let the kememdup_array() take care about multiplication and possible >> overflows. >> >> Signed-off-by: Andy Shevchenko >> --- >>   drivers/acpi/arm64/iort.c | 2 +- >>   1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c >> index c0b1c2c19444..e596dff20f1e 100644 >> --- a/drivers/acpi/arm64/iort.c >> +++ b/drivers/acpi/arm64/iort.c >> @@ -822,7 +822,7 @@ static struct iommu_iort_rmr_data *iort_rmr_alloc( >>           return NULL; >>       /* Create a copy of SIDs array to associate with this rmr_data */ >> -    sids_copy = kmemdup(sids, num_sids * sizeof(*sids), GFP_KERNEL); >> +    sids_copy = kmemdup_array(sids, num_sids, sizeof(*sids), >> GFP_KERNEL); >>       if (!sids_copy) { >>           kfree(rmr_data); >>           return NULL; > > Looks good to me, > > Acked-by: Hanjun Guo Catalin, would you mind pick this up as well? Thanks Hanjun