diff mbox series

[v1,1/1] ACPI/IORT: Switch to use kmemdup_array()

Message ID 20240606165005.3031490-1-andriy.shevchenko@linux.intel.com
State Accepted
Commit 9cd8062b38e61f11054f13b3c98695c7b1d73b11
Headers show
Series [v1,1/1] ACPI/IORT: Switch to use kmemdup_array() | expand

Commit Message

Andy Shevchenko June 6, 2024, 4:50 p.m. UTC
Let the kememdup_array() take care about multiplication and possible
overflows.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/arm64/iort.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hanjun Guo June 11, 2024, 10:42 a.m. UTC | #1
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 <andriy.shevchenko@linux.intel.com>
> ---
>   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 <guohanjun@huawei.com>
Hanjun Guo June 14, 2024, 12:54 a.m. UTC | #2
+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 <andriy.shevchenko@linux.intel.com>
>> ---
>>   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 <guohanjun@huawei.com>

Catalin, would you mind pick this up as well?

Thanks
Hanjun
Hanjun Guo Aug. 9, 2024, 12:52 p.m. UTC | #3
On 2024/8/9 20:16, Andy Shevchenko wrote:
> On Fri, Jun 14, 2024 at 08:54:39AM +0800, Hanjun Guo wrote:
>> +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 <andriy.shevchenko@linux.intel.com>
>>>> ---
>>>>    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 <guohanjun@huawei.com>
>>
>> Catalin, would you mind pick this up as well?
> 
> Any news?
> 
> I do not see this even in Linux Next...

Sudeep, Lorenzo, would you mind giving it a go?

Thanks
Hanjun
Hanjun Guo Aug. 9, 2024, 1:16 p.m. UTC | #4
On 2024/8/9 20:52, Catalin Marinas wrote:
> On Fri, Aug 09, 2024 at 03:16:34PM +0300, Andy Shevchenko wrote:
>> On Fri, Jun 14, 2024 at 08:54:39AM +0800, Hanjun Guo wrote:
>>> +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 <andriy.shevchenko@linux.intel.com>
>>>>> ---
>>>>>    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 <guohanjun@huawei.com>
>>>
>>> Catalin, would you mind pick this up as well?
>>
>> Any news?
>>
>> I do not see this even in Linux Next...
> 
> Ah, sorry, I missed this. Since it doesn't look like a fix, I guess it's
> fine to go in 6.12. Adding Will since he's handling the upcoming merging
> window.

Sorry, I sent another email almost at the same time, so missed this one.

Thanks
Hanjun
Andy Shevchenko Aug. 9, 2024, 1:46 p.m. UTC | #5
On Fri, Aug 09, 2024 at 01:52:48PM +0100, Catalin Marinas wrote:
> On Fri, Aug 09, 2024 at 03:16:34PM +0300, Andy Shevchenko wrote:

...

> Ah, sorry, I missed this. Since it doesn't look like a fix, I guess it's
> fine to go in 6.12.

No, it's definitely not a fix, it's a simple cleanup.
Hence v6.12 is quite okay, thanks!
Will Deacon Aug. 16, 2024, 3:15 p.m. UTC | #6
On Thu, 06 Jun 2024 19:50:05 +0300, Andy Shevchenko wrote:
> Let the kememdup_array() take care about multiplication and possible
> overflows.
> 
> 

Applied to arm64 (for-next/acpi), thanks!

[1/1] ACPI/IORT: Switch to use kmemdup_array()
      https://git.kernel.org/arm64/c/9cd8062b38e6

Cheers,
diff mbox series

Patch

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;