CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Ian Pilcher <[email protected]>
TO: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

Hi Ian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on 5d6ab0bb408ffdaac585982faa9ec8c7d5cc349f]

url:    
https://github.com/0day-ci/linux/commits/Ian-Pilcher/Introduce-block-device-LED-trigger/20211009-234152
base:   5d6ab0bb408ffdaac585982faa9ec8c7d5cc349f
:::::: branch date: 4 days ago
:::::: commit date: 4 days ago
config: x86_64-randconfig-m031-20211013 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

smatch warnings:
drivers/leds/trigger/ledtrig-blkdev.c:164 blkdev_trig_activate() warn: possible 
memory leak of 'led'

vim +/led +164 drivers/leds/trigger/ledtrig-blkdev.c

91067f793c78d0 Ian Pilcher 2021-10-09  119  
91067f793c78d0 Ian Pilcher 2021-10-09  120  /**
91067f793c78d0 Ian Pilcher 2021-10-09  121   * blkdev_trig_activate() - Called 
when an LED is associated with the trigger.
91067f793c78d0 Ian Pilcher 2021-10-09  122   * @led_cdev:       The LED
91067f793c78d0 Ian Pilcher 2021-10-09  123   *
91067f793c78d0 Ian Pilcher 2021-10-09  124   * Allocates & initializes the 
@blkdev_trig_led structure, adds it to the
91067f793c78d0 Ian Pilcher 2021-10-09  125   * @blkdev_trig_all_leds list, and 
sets the LED's trigger data.
91067f793c78d0 Ian Pilcher 2021-10-09  126   *
91067f793c78d0 Ian Pilcher 2021-10-09  127   * Context: Process context.  Takes 
and releases @blkdev_trig_mutex.
91067f793c78d0 Ian Pilcher 2021-10-09  128   * Return:  ``0`` on success, 
``-errno`` on error.
91067f793c78d0 Ian Pilcher 2021-10-09  129   */
91067f793c78d0 Ian Pilcher 2021-10-09  130  static int 
blkdev_trig_activate(struct led_classdev *led_cdev)
91067f793c78d0 Ian Pilcher 2021-10-09  131  {
91067f793c78d0 Ian Pilcher 2021-10-09  132      struct blkdev_trig_led *led;
91067f793c78d0 Ian Pilcher 2021-10-09  133      int err;
91067f793c78d0 Ian Pilcher 2021-10-09  134  
91067f793c78d0 Ian Pilcher 2021-10-09  135      led = kzalloc(sizeof(*led), 
GFP_KERNEL);
91067f793c78d0 Ian Pilcher 2021-10-09  136      if (led == NULL)
91067f793c78d0 Ian Pilcher 2021-10-09  137              return -ENOMEM;
91067f793c78d0 Ian Pilcher 2021-10-09  138  
91067f793c78d0 Ian Pilcher 2021-10-09  139      err = 
mutex_lock_interruptible(&blkdev_trig_mutex);
91067f793c78d0 Ian Pilcher 2021-10-09  140      if (err)
91067f793c78d0 Ian Pilcher 2021-10-09  141              goto exit_free;
91067f793c78d0 Ian Pilcher 2021-10-09  142  
91067f793c78d0 Ian Pilcher 2021-10-09  143      if (blkdev_trig_next_index == 
ULONG_MAX) {
91067f793c78d0 Ian Pilcher 2021-10-09  144              err = -EOVERFLOW;
91067f793c78d0 Ian Pilcher 2021-10-09  145              goto exit_unlock;
91067f793c78d0 Ian Pilcher 2021-10-09  146      }
91067f793c78d0 Ian Pilcher 2021-10-09  147  
91067f793c78d0 Ian Pilcher 2021-10-09  148      led->index = 
blkdev_trig_next_index++;
91067f793c78d0 Ian Pilcher 2021-10-09  149      led->last_checked = jiffies;
91067f793c78d0 Ian Pilcher 2021-10-09  150      led->mode = -1;  /* set all 
bits */
91067f793c78d0 Ian Pilcher 2021-10-09  151      led->led_cdev = led_cdev;
91067f793c78d0 Ian Pilcher 2021-10-09  152      led->blink_msec = 
BLKDEV_TRIG_BLINK_DEF;
91067f793c78d0 Ian Pilcher 2021-10-09  153      led->check_jiffies = 
msecs_to_jiffies(BLKDEV_TRIG_CHECK_DEF);
91067f793c78d0 Ian Pilcher 2021-10-09  154      xa_init(&led->linked_btbs);
91067f793c78d0 Ian Pilcher 2021-10-09  155  
91067f793c78d0 Ian Pilcher 2021-10-09  156      
hlist_add_head(&led->all_leds_node, &blkdev_trig_all_leds);
91067f793c78d0 Ian Pilcher 2021-10-09  157      led_set_trigger_data(led_cdev, 
led);
91067f793c78d0 Ian Pilcher 2021-10-09  158  
91067f793c78d0 Ian Pilcher 2021-10-09  159  exit_unlock:
91067f793c78d0 Ian Pilcher 2021-10-09  160      
mutex_unlock(&blkdev_trig_mutex);
91067f793c78d0 Ian Pilcher 2021-10-09  161  exit_free:
91067f793c78d0 Ian Pilcher 2021-10-09  162      if (err)
91067f793c78d0 Ian Pilcher 2021-10-09  163              kfree(led);
91067f793c78d0 Ian Pilcher 2021-10-09 @164      return err;
91067f793c78d0 Ian Pilcher 2021-10-09  165  }
91067f793c78d0 Ian Pilcher 2021-10-09  166  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to