diff options
author | Sven Wegener <sven.wegener@stealer.net> | 2008-08-01 15:57:16 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-08-04 15:09:11 -0400 |
commit | 5cbbb376d65ed181ed290cea505ba37a0425ee25 (patch) | |
tree | cd4f4f596032cbbf996e6d2ae660bdeecadd38b3 /drivers | |
parent | 4fc22b21b3fcb3580c32b70605ef114178f8e611 (diff) |
iwlwifi: Don't use buffer allocated on the stack for led names
Having the buffer on the stack and even re-using it for all led devices is bad.
Not being able to resolve the name member of the led device structure to a
meaningful value leads to confusion during ad-hoc debugging and potential
breakage in the future, if we ever decide to access the name member outside of
the registration function. Move the buffer to our private per led device
structures so that it is accessible after registration.
A quick grep didn't yield any occurence of using the led device name parameter
outside of the led device registration function, so currently we should already
be safe for normal operation.
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
Cc: Richard Purdie <rpurdie@rpsys.net>
Acked-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-led.c | 33 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-led.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-led.c | 29 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-led.h | 1 |
4 files changed, 36 insertions, 28 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.c b/drivers/net/wireless/iwlwifi/iwl-3945-led.c index 6be1fe13fa57..d3336966b6b5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.c | |||
@@ -206,12 +206,12 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev, | |||
206 | static int iwl3945_led_register_led(struct iwl3945_priv *priv, | 206 | static int iwl3945_led_register_led(struct iwl3945_priv *priv, |
207 | struct iwl3945_led *led, | 207 | struct iwl3945_led *led, |
208 | enum led_type type, u8 set_led, | 208 | enum led_type type, u8 set_led, |
209 | const char *name, char *trigger) | 209 | char *trigger) |
210 | { | 210 | { |
211 | struct device *device = wiphy_dev(priv->hw->wiphy); | 211 | struct device *device = wiphy_dev(priv->hw->wiphy); |
212 | int ret; | 212 | int ret; |
213 | 213 | ||
214 | led->led_dev.name = name; | 214 | led->led_dev.name = led->name; |
215 | led->led_dev.brightness_set = iwl3945_led_brightness_set; | 215 | led->led_dev.brightness_set = iwl3945_led_brightness_set; |
216 | led->led_dev.default_trigger = trigger; | 216 | led->led_dev.default_trigger = trigger; |
217 | 217 | ||
@@ -308,7 +308,6 @@ void iwl3945_led_background(struct iwl3945_priv *priv) | |||
308 | int iwl3945_led_register(struct iwl3945_priv *priv) | 308 | int iwl3945_led_register(struct iwl3945_priv *priv) |
309 | { | 309 | { |
310 | char *trigger; | 310 | char *trigger; |
311 | char name[32]; | ||
312 | int ret; | 311 | int ret; |
313 | 312 | ||
314 | priv->last_blink_rate = 0; | 313 | priv->last_blink_rate = 0; |
@@ -318,7 +317,8 @@ int iwl3945_led_register(struct iwl3945_priv *priv) | |||
318 | priv->allow_blinking = 0; | 317 | priv->allow_blinking = 0; |
319 | 318 | ||
320 | trigger = ieee80211_get_radio_led_name(priv->hw); | 319 | trigger = ieee80211_get_radio_led_name(priv->hw); |
321 | snprintf(name, sizeof(name), "iwl-%s:radio", | 320 | snprintf(priv->led[IWL_LED_TRG_RADIO].name, |
321 | sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s:radio", | ||
322 | wiphy_name(priv->hw->wiphy)); | 322 | wiphy_name(priv->hw->wiphy)); |
323 | 323 | ||
324 | priv->led[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on; | 324 | priv->led[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on; |
@@ -327,19 +327,20 @@ int iwl3945_led_register(struct iwl3945_priv *priv) | |||
327 | 327 | ||
328 | ret = iwl3945_led_register_led(priv, | 328 | ret = iwl3945_led_register_led(priv, |
329 | &priv->led[IWL_LED_TRG_RADIO], | 329 | &priv->led[IWL_LED_TRG_RADIO], |
330 | IWL_LED_TRG_RADIO, 1, | 330 | IWL_LED_TRG_RADIO, 1, trigger); |
331 | name, trigger); | 331 | |
332 | if (ret) | 332 | if (ret) |
333 | goto exit_fail; | 333 | goto exit_fail; |
334 | 334 | ||
335 | trigger = ieee80211_get_assoc_led_name(priv->hw); | 335 | trigger = ieee80211_get_assoc_led_name(priv->hw); |
336 | snprintf(name, sizeof(name), "iwl-%s:assoc", | 336 | snprintf(priv->led[IWL_LED_TRG_ASSOC].name, |
337 | sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s:assoc", | ||
337 | wiphy_name(priv->hw->wiphy)); | 338 | wiphy_name(priv->hw->wiphy)); |
338 | 339 | ||
339 | ret = iwl3945_led_register_led(priv, | 340 | ret = iwl3945_led_register_led(priv, |
340 | &priv->led[IWL_LED_TRG_ASSOC], | 341 | &priv->led[IWL_LED_TRG_ASSOC], |
341 | IWL_LED_TRG_ASSOC, 0, | 342 | IWL_LED_TRG_ASSOC, 0, trigger); |
342 | name, trigger); | 343 | |
343 | /* for assoc always turn led on */ | 344 | /* for assoc always turn led on */ |
344 | priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on; | 345 | priv->led[IWL_LED_TRG_ASSOC].led_on = iwl3945_led_on; |
345 | priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on; | 346 | priv->led[IWL_LED_TRG_ASSOC].led_off = iwl3945_led_on; |
@@ -349,14 +350,13 @@ int iwl3945_led_register(struct iwl3945_priv *priv) | |||
349 | goto exit_fail; | 350 | goto exit_fail; |
350 | 351 | ||
351 | trigger = ieee80211_get_rx_led_name(priv->hw); | 352 | trigger = ieee80211_get_rx_led_name(priv->hw); |
352 | snprintf(name, sizeof(name), "iwl-%s:RX", | 353 | snprintf(priv->led[IWL_LED_TRG_RX].name, |
354 | sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s:RX", | ||
353 | wiphy_name(priv->hw->wiphy)); | 355 | wiphy_name(priv->hw->wiphy)); |
354 | 356 | ||
355 | |||
356 | ret = iwl3945_led_register_led(priv, | 357 | ret = iwl3945_led_register_led(priv, |
357 | &priv->led[IWL_LED_TRG_RX], | 358 | &priv->led[IWL_LED_TRG_RX], |
358 | IWL_LED_TRG_RX, 0, | 359 | IWL_LED_TRG_RX, 0, trigger); |
359 | name, trigger); | ||
360 | 360 | ||
361 | priv->led[IWL_LED_TRG_RX].led_on = iwl3945_led_associated; | 361 | priv->led[IWL_LED_TRG_RX].led_on = iwl3945_led_associated; |
362 | priv->led[IWL_LED_TRG_RX].led_off = iwl3945_led_associated; | 362 | priv->led[IWL_LED_TRG_RX].led_off = iwl3945_led_associated; |
@@ -366,13 +366,14 @@ int iwl3945_led_register(struct iwl3945_priv *priv) | |||
366 | goto exit_fail; | 366 | goto exit_fail; |
367 | 367 | ||
368 | trigger = ieee80211_get_tx_led_name(priv->hw); | 368 | trigger = ieee80211_get_tx_led_name(priv->hw); |
369 | snprintf(name, sizeof(name), "iwl-%s:TX", | 369 | snprintf(priv->led[IWL_LED_TRG_TX].name, |
370 | sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s:TX", | ||
370 | wiphy_name(priv->hw->wiphy)); | 371 | wiphy_name(priv->hw->wiphy)); |
371 | 372 | ||
372 | ret = iwl3945_led_register_led(priv, | 373 | ret = iwl3945_led_register_led(priv, |
373 | &priv->led[IWL_LED_TRG_TX], | 374 | &priv->led[IWL_LED_TRG_TX], |
374 | IWL_LED_TRG_TX, 0, | 375 | IWL_LED_TRG_TX, 0, trigger); |
375 | name, trigger); | 376 | |
376 | priv->led[IWL_LED_TRG_TX].led_on = iwl3945_led_associated; | 377 | priv->led[IWL_LED_TRG_TX].led_on = iwl3945_led_associated; |
377 | priv->led[IWL_LED_TRG_TX].led_off = iwl3945_led_associated; | 378 | priv->led[IWL_LED_TRG_TX].led_off = iwl3945_led_associated; |
378 | priv->led[IWL_LED_TRG_TX].led_pattern = iwl3945_led_pattern; | 379 | priv->led[IWL_LED_TRG_TX].led_pattern = iwl3945_led_pattern; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.h b/drivers/net/wireless/iwlwifi/iwl-3945-led.h index 47b7e0bac802..2fbd126c1347 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-led.h +++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.h | |||
@@ -50,6 +50,7 @@ enum led_type { | |||
50 | struct iwl3945_led { | 50 | struct iwl3945_led { |
51 | struct iwl3945_priv *priv; | 51 | struct iwl3945_priv *priv; |
52 | struct led_classdev led_dev; | 52 | struct led_classdev led_dev; |
53 | char name[32]; | ||
53 | 54 | ||
54 | int (*led_on) (struct iwl3945_priv *priv, int led_id); | 55 | int (*led_on) (struct iwl3945_priv *priv, int led_id); |
55 | int (*led_off) (struct iwl3945_priv *priv, int led_id); | 56 | int (*led_off) (struct iwl3945_priv *priv, int led_id); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c index 0a01f091c516..cb11c4a4d691 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/drivers/net/wireless/iwlwifi/iwl-led.c | |||
@@ -242,12 +242,12 @@ static void iwl_led_brightness_set(struct led_classdev *led_cdev, | |||
242 | */ | 242 | */ |
243 | static int iwl_leds_register_led(struct iwl_priv *priv, struct iwl_led *led, | 243 | static int iwl_leds_register_led(struct iwl_priv *priv, struct iwl_led *led, |
244 | enum led_type type, u8 set_led, | 244 | enum led_type type, u8 set_led, |
245 | const char *name, char *trigger) | 245 | char *trigger) |
246 | { | 246 | { |
247 | struct device *device = wiphy_dev(priv->hw->wiphy); | 247 | struct device *device = wiphy_dev(priv->hw->wiphy); |
248 | int ret; | 248 | int ret; |
249 | 249 | ||
250 | led->led_dev.name = name; | 250 | led->led_dev.name = led->name; |
251 | led->led_dev.brightness_set = iwl_led_brightness_set; | 251 | led->led_dev.brightness_set = iwl_led_brightness_set; |
252 | led->led_dev.default_trigger = trigger; | 252 | led->led_dev.default_trigger = trigger; |
253 | 253 | ||
@@ -345,7 +345,6 @@ EXPORT_SYMBOL(iwl_leds_background); | |||
345 | int iwl_leds_register(struct iwl_priv *priv) | 345 | int iwl_leds_register(struct iwl_priv *priv) |
346 | { | 346 | { |
347 | char *trigger; | 347 | char *trigger; |
348 | char name[32]; | ||
349 | int ret; | 348 | int ret; |
350 | 349 | ||
351 | priv->last_blink_rate = 0; | 350 | priv->last_blink_rate = 0; |
@@ -354,7 +353,8 @@ int iwl_leds_register(struct iwl_priv *priv) | |||
354 | priv->allow_blinking = 0; | 353 | priv->allow_blinking = 0; |
355 | 354 | ||
356 | trigger = ieee80211_get_radio_led_name(priv->hw); | 355 | trigger = ieee80211_get_radio_led_name(priv->hw); |
357 | snprintf(name, sizeof(name), "iwl-%s:radio", | 356 | snprintf(priv->led[IWL_LED_TRG_RADIO].name, |
357 | sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s:radio", | ||
358 | wiphy_name(priv->hw->wiphy)); | 358 | wiphy_name(priv->hw->wiphy)); |
359 | 359 | ||
360 | priv->led[IWL_LED_TRG_RADIO].led_on = iwl4965_led_on_reg; | 360 | priv->led[IWL_LED_TRG_RADIO].led_on = iwl4965_led_on_reg; |
@@ -362,16 +362,17 @@ int iwl_leds_register(struct iwl_priv *priv) | |||
362 | priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL; | 362 | priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL; |
363 | 363 | ||
364 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RADIO], | 364 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RADIO], |
365 | IWL_LED_TRG_RADIO, 1, name, trigger); | 365 | IWL_LED_TRG_RADIO, 1, trigger); |
366 | if (ret) | 366 | if (ret) |
367 | goto exit_fail; | 367 | goto exit_fail; |
368 | 368 | ||
369 | trigger = ieee80211_get_assoc_led_name(priv->hw); | 369 | trigger = ieee80211_get_assoc_led_name(priv->hw); |
370 | snprintf(name, sizeof(name), "iwl-%s:assoc", | 370 | snprintf(priv->led[IWL_LED_TRG_ASSOC].name, |
371 | sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s:assoc", | ||
371 | wiphy_name(priv->hw->wiphy)); | 372 | wiphy_name(priv->hw->wiphy)); |
372 | 373 | ||
373 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_ASSOC], | 374 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_ASSOC], |
374 | IWL_LED_TRG_ASSOC, 0, name, trigger); | 375 | IWL_LED_TRG_ASSOC, 0, trigger); |
375 | 376 | ||
376 | /* for assoc always turn led on */ | 377 | /* for assoc always turn led on */ |
377 | priv->led[IWL_LED_TRG_ASSOC].led_on = iwl_led_associate; | 378 | priv->led[IWL_LED_TRG_ASSOC].led_on = iwl_led_associate; |
@@ -382,11 +383,12 @@ int iwl_leds_register(struct iwl_priv *priv) | |||
382 | goto exit_fail; | 383 | goto exit_fail; |
383 | 384 | ||
384 | trigger = ieee80211_get_rx_led_name(priv->hw); | 385 | trigger = ieee80211_get_rx_led_name(priv->hw); |
385 | snprintf(name, sizeof(name), "iwl-%s:RX", wiphy_name(priv->hw->wiphy)); | 386 | snprintf(priv->led[IWL_LED_TRG_RX].name, |
386 | 387 | sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s:RX", | |
388 | wiphy_name(priv->hw->wiphy)); | ||
387 | 389 | ||
388 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RX], | 390 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RX], |
389 | IWL_LED_TRG_RX, 0, name, trigger); | 391 | IWL_LED_TRG_RX, 0, trigger); |
390 | 392 | ||
391 | priv->led[IWL_LED_TRG_RX].led_on = iwl_led_associated; | 393 | priv->led[IWL_LED_TRG_RX].led_on = iwl_led_associated; |
392 | priv->led[IWL_LED_TRG_RX].led_off = iwl_led_associated; | 394 | priv->led[IWL_LED_TRG_RX].led_off = iwl_led_associated; |
@@ -396,9 +398,12 @@ int iwl_leds_register(struct iwl_priv *priv) | |||
396 | goto exit_fail; | 398 | goto exit_fail; |
397 | 399 | ||
398 | trigger = ieee80211_get_tx_led_name(priv->hw); | 400 | trigger = ieee80211_get_tx_led_name(priv->hw); |
399 | snprintf(name, sizeof(name), "iwl-%s:TX", wiphy_name(priv->hw->wiphy)); | 401 | snprintf(priv->led[IWL_LED_TRG_TX].name, |
402 | sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s:TX", | ||
403 | wiphy_name(priv->hw->wiphy)); | ||
404 | |||
400 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_TX], | 405 | ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_TX], |
401 | IWL_LED_TRG_TX, 0, name, trigger); | 406 | IWL_LED_TRG_TX, 0, trigger); |
402 | 407 | ||
403 | priv->led[IWL_LED_TRG_TX].led_on = iwl_led_associated; | 408 | priv->led[IWL_LED_TRG_TX].led_on = iwl_led_associated; |
404 | priv->led[IWL_LED_TRG_TX].led_off = iwl_led_associated; | 409 | priv->led[IWL_LED_TRG_TX].led_off = iwl_led_associated; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.h b/drivers/net/wireless/iwlwifi/iwl-led.h index 1980ae5a7e82..588c9ad20e83 100644 --- a/drivers/net/wireless/iwlwifi/iwl-led.h +++ b/drivers/net/wireless/iwlwifi/iwl-led.h | |||
@@ -52,6 +52,7 @@ enum led_type { | |||
52 | struct iwl_led { | 52 | struct iwl_led { |
53 | struct iwl_priv *priv; | 53 | struct iwl_priv *priv; |
54 | struct led_classdev led_dev; | 54 | struct led_classdev led_dev; |
55 | char name[32]; | ||
55 | 56 | ||
56 | int (*led_on) (struct iwl_priv *priv, int led_id); | 57 | int (*led_on) (struct iwl_priv *priv, int led_id); |
57 | int (*led_off) (struct iwl_priv *priv, int led_id); | 58 | int (*led_off) (struct iwl_priv *priv, int led_id); |