From a8716d13bfba9345d05b6078dfff018371587d16 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 2 Mar 2014 15:12:21 +0200 Subject: [PATCH] roboswitch: Verify that register read succeeds before comparing result If wpa_driver_roboswitch_read() fails before such comparison, the values that are being compared are not initialized properly and as such, there is not much point in comparing them either. Signed-off-by: Jouni Malinen --- src/drivers/driver_roboswitch.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/drivers/driver_roboswitch.c b/src/drivers/driver_roboswitch.c index 0a9078a4a..9ce3fa2f0 100644 --- a/src/drivers/driver_roboswitch.c +++ b/src/drivers/driver_roboswitch.c @@ -260,17 +260,17 @@ static int wpa_driver_roboswitch_join(struct wpa_driver_roboswitch_data *drv, ROBO_ARLCTRL_CONF, read1, 1); } else { /* if both multiport addresses are the same we can add */ - wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, - ROBO_ARLCTRL_ADDR_1, read1, 3); - wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, - ROBO_ARLCTRL_ADDR_2, read2, 3); - if (os_memcmp(read1, read2, 6) != 0) + if (wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, + ROBO_ARLCTRL_ADDR_1, read1, 3) || + wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, + ROBO_ARLCTRL_ADDR_2, read2, 3) || + os_memcmp(read1, read2, 6) != 0) return -1; - wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, - ROBO_ARLCTRL_VEC_1, read1, 1); - wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, - ROBO_ARLCTRL_VEC_2, read2, 1); - if (read1[0] != read2[0]) + if (wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, + ROBO_ARLCTRL_VEC_1, read1, 1) || + wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, + ROBO_ARLCTRL_VEC_2, read2, 1) || + read1[0] != read2[0]) return -1; wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, ROBO_ARLCTRL_ADDR_1, addr_be16, 3);