Patch "ACPI: property: Fix return value for nval == 0 in acpi_data_prop_read()" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ACPI: property: Fix return value for nval == 0 in acpi_data_prop_read()

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     acpi-property-fix-return-value-for-nval-0-in-acpi_da.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 12d6b0c64a6edd2d782074a926a63be1bdcd8330
Author: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Date:   Mon Feb 3 21:46:29 2025 +0200

    ACPI: property: Fix return value for nval == 0 in acpi_data_prop_read()
    
    [ Upstream commit ab930483eca9f3e816c35824b5868599af0c61d7 ]
    
    While analysing code for software and OF node for the corner case when
    caller asks to read zero items in the supposed to be an array of values
    I found that ACPI behaves differently to what OF does, i.e.
    
     1. It returns -EINVAL when caller asks to read zero items from integer
        array, while OF returns 0, if no other errors happened.
    
     2. It returns -EINVAL when caller asks to read zero items from string
        array, while OF returns -ENODATA, if no other errors happened.
    
    Amend ACPI implementation to follow what OF does.
    
    Fixes: b31384fa5de3 ("Driver core: Unified device properties interface for platform firmware")
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
    Link: https://patch.msgid.link/20250203194629.3731895-1-andriy.shevchenko@xxxxxxxxxxxxxxx
    [ rjw: Added empty line after a conditional ]
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 80a52a4e66dd1..e9186339f6e6b 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1187,8 +1187,6 @@ static int acpi_data_prop_read(const struct acpi_device_data *data,
 		}
 		break;
 	}
-	if (nval == 0)
-		return -EINVAL;
 
 	if (obj->type == ACPI_TYPE_BUFFER) {
 		if (proptype != DEV_PROP_U8)
@@ -1212,9 +1210,11 @@ static int acpi_data_prop_read(const struct acpi_device_data *data,
 		ret = acpi_copy_property_array_uint(items, (u64 *)val, nval);
 		break;
 	case DEV_PROP_STRING:
-		ret = acpi_copy_property_array_string(
-			items, (char **)val,
-			min_t(u32, nval, obj->package.count));
+		nval = min_t(u32, nval, obj->package.count);
+		if (nval == 0)
+			return -ENODATA;
+
+		ret = acpi_copy_property_array_string(items, (char **)val, nval);
 		break;
 	default:
 		ret = -EINVAL;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux