aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-led.c
diff options
context:
space:
mode:
authorSven Wegener <sven.wegener@stealer.net>2008-08-01 15:57:16 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-04 15:09:11 -0400
commit5cbbb376d65ed181ed290cea505ba37a0425ee25 (patch)
treecd4f4f596032cbbf996e6d2ae660bdeecadd38b3 /drivers/net/wireless/iwlwifi/iwl-led.c
parent4fc22b21b3fcb3580c32b70605ef114178f8e611 (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/net/wireless/iwlwifi/iwl-led.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.c29
1 files changed, 17 insertions, 12 deletions
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 */
243static int iwl_leds_register_led(struct iwl_priv *priv, struct iwl_led *led, 243static 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);
345int iwl_leds_register(struct iwl_priv *priv) 345int 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;