[PATCH] drivers: firmware: arm-scmi: Fix iterating over idr

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Dec 4 01:06:17 PST 2023


On 04.12.23 08:28, Sascha Hauer wrote:
> The iterator in idr_for_each_entry() is the pointer we store in the idr,
> not the idr element itself.
> 
> Fixes: d28d3d9159 ("include: linux/idr.h: implement more Linux API")
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>


> ---
>  drivers/firmware/arm_scmi/driver.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 98f6727465..19fb77f4ea 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -990,9 +990,9 @@ int scmi_protocol_device_request(const struct scmi_device_id *id_table)
>  {
>  	int id, ret = 0;
>  	struct list_head *phead = NULL;
> +	struct list_head *head;
>  	struct scmi_requested_dev *rdev;
>  	struct scmi_info *info;
> -	struct idr *idr;
>  
>  	pr_debug("Requesting SCMI device (%s) for protocol 0x%x\n",
>  		 id_table->name, id_table->protocol_id);
> @@ -1001,8 +1001,7 @@ int scmi_protocol_device_request(const struct scmi_device_id *id_table)
>  	 * Search for the matching protocol rdev list and then search
>  	 * of any existent equally named device...fails if any duplicate found.
>  	 */
> -	idr_for_each_entry(&scmi_requested_devices, idr, id) {
> -		struct list_head *head = idr->ptr;
> +	idr_for_each_entry(&scmi_requested_devices, head, id) {
>  		if (!phead) {
>  			/* A list found registered in the IDR is never empty */
>  			rdev = list_first_entry(head, struct scmi_requested_dev,

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




More information about the barebox mailing list