Skip to contentSkip to conversation

mac802154: Prevent overwrite return code in mac802154_perform_association()

PATCH Applied Robertus Diawan Chris 4 participants 4 messages Jun 2 – Jun 19

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac802154: Prevent overwrite return code in mac802154_perform_association()

When assoc_status not equal to IEEE802154_ASSOCIATION_SUCCESSFUL, the return value assigned to either "-ERANGE" or "-EPERM" but this return value will be overwritten to 0 after exiting the conditional scope. So, jump to clear_assoc label to preserve the return value when assoc_status not equal to IEEE802154_ASSOCIATION_SUCCESSFUL.

This is reported by Coverity Scan as "Unused value".

Fixes fefd19807fe9 ("mac802154: Handle associating")

---
I am still not sure how to test this change. I look around the function and use the previous error handler as a guidance to make this change, like error handler for "No ASSOC REQ ACK received" and "No ASSOC RESP received".

Thank you.

 net/mac802154/scan.c | 1 +
 1 file changed, 1 insertion(+)
net/mac802154/scan.c +1 -0
index 0a31ac8d8415..300d4584533e 100644
@@ -594,6 +594,7 @@ int mac802154_perform_association(struct ieee802154_sub_if_data *sdata,
 			 "Negative ASSOC RESP received from %8phC: %s\n", &ceaddr,
 			 local->assoc_status == IEEE802154_PAN_AT_CAPACITY ?
 			 "PAN at capacity" : "access denied");
+		goto clear_assoc;
 	}
 
 	ret = 0;

base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8

Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hello,

Quoted 10 lines · Robertus Diawan Chris

When assoc_status not equal to IEEE802154_ASSOCIATION_SUCCESSFUL, the return value assigned to either "-ERANGE" or "-EPERM" but this return value will be overwritten to 0 after exiting the conditional scope. So, jump to clear_assoc label to preserve the return value when assoc_status not equal to IEEE802154_ASSOCIATION_SUCCESSFUL.

This is reported by Coverity Scan as "Unused value".

Fixes fefd19807fe9 ("mac802154: Handle associating")

This is correct.

Thanks,
Miquèl

reviewer
#2 lore raw
In reply to Robertus Diawan Chris
Quoted 10 lines · Robertus Diawan Chris

When assoc_status not equal to IEEE802154_ASSOCIATION_SUCCESSFUL, the return value assigned to either "-ERANGE" or "-EPERM" but this return value will be overwritten to 0 after exiting the conditional scope. So, jump to clear_assoc label to preserve the return value when assoc_status not equal to IEEE802154_ASSOCIATION_SUCCESSFUL.

This is reported by Coverity Scan as "Unused value".

Fixes fefd19807fe9 ("mac802154: Handle associating")

FTR: An AI generated review of this patch is available on sashiko.dev. I believe that review can be treated in the context of possible follow-up and should not effect the progress of this patch.

maintainer Applied
#3 lore raw
In reply to Robertus Diawan Chris

Hello Robertus Diawan Chris.

Quoted 9 lines · Robertus Diawan Chris

When assoc_status not equal to IEEE802154_ASSOCIATION_SUCCESSFUL, the return value assigned to either "-ERANGE" or "-EPERM" but this return value will be overwritten to 0 after exiting the conditional scope. So, jump to clear_assoc label to preserve the return value when assoc_status not equal to IEEE802154_ASSOCIATION_SUCCESSFUL.

This is reported by Coverity Scan as "Unused value".

[...]

Applied to wpan/wpan-next.git, thanks!

[1/1] mac802154: Prevent overwrite return code in mac802154_perform_association()

      https://git.kernel.org/wpan/wpan-next/c/649147cb3f8b

regards,
Stefan Schmidt