Skip to contentSkip to conversation

caif: checking the wrong variable

PATCH Applied Dan Carpenter 3 participants 3 messages Jan 15, 2011 – Jan 16, 2011

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

PATCH 1/1 caif: checking the wrong variable

In the original code we check if (servl = NULL) twice. The first time should print the message that cfmuxl_remove_uplayer() failed and set "ret" correctly, but instead it just returns success. The second check should be checking the value of "ret" instead of "servl".

net/caif/cfcnfg.c +5 -4
index 21ede14..c665de7 100644
@@ -191,6 +191,7 @@ int cfcnfg_disconn_adapt_layer(struct cfcnfg *cnfg, struct cflayer *adap_layer)
 	struct cflayer *servl = NULL;
 	struct cfcnfg_phyinfo *phyinfo = NULL;
 	u8 phyid = 0;
+
 	caif_assert(adap_layer != NULL);
 	channel_id = adap_layer->id;
 	if (adap_layer->dn = NULL || channel_id = 0) {
@@ -199,16 +200,16 @@ int cfcnfg_disconn_adapt_layer(struct cfcnfg *cnfg, struct cflayer *adap_layer)
 		goto end;
 	}
 	servl = cfmuxl_remove_uplayer(cnfg->mux, channel_id);
-	if (servl = NULL)
-		goto end;
-	layer_set_up(servl, NULL);
-	ret = cfctrl_linkdown_req(cnfg->ctrl, channel_id, adap_layer);
 	if (servl = NULL) {
 		pr_err("PROTOCOL ERROR - Error removing service_layer Channel_Id(%d)",
 		       channel_id);
 		ret = -EINVAL;
 		goto end;
 	}
+	layer_set_up(servl, NULL);
+	ret = cfctrl_linkdown_req(cnfg->ctrl, channel_id, adap_layer);
+	if (ret)
+		goto end;
 	caif_assert(channel_id = servl->id);
 	if (adap_layer->dn != NULL) {
 		phyid = cfsrvl_getphyid(adap_layer->dn);
Acked-by Sjur Braendeland on v1 1/1
#1 lore raw
Quoted 6 lines

In the original code we check if (servl = NULL) twice.  The first time should print the message that cfmuxl_remove_uplayer() failed and set "ret" correctly, but instead it just returns success.  The second check should be checking the value of "ret" instead of "servl".

Thank you for spotting and correcting this.
Looks good to me (reviewed only)

maintainer Applied
#2 lore raw

From: Sjur Brændeland <[email protected]>
Date: Sat, 15 Jan 2011 15:03:31 +0100

Quoted 11 lines
Quoted 6 lines

In the original code we check if (servl == NULL) twice.  The first time should print the message that cfmuxl_remove_uplayer() failed and set "ret" correctly, but instead it just returns success.  The second check should be checking the value of "ret" instead of "servl".

Thank you for spotting and correcting this.
Looks good to me (reviewed only)

Applied, thanks.