[kbuild] Re: [PATCH v4 3/5] usb: gadget: add trace event of configfs group operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Linyu,

url:    https://github.com/intel-lab-lkp/linux/commits/Linyu-Yuan/usb-gadget-configfs-new-trace-events/20220330-141926 
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git  usb-testing
config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20220331/202203311137.r3Nm4dyZ-lkp@xxxxxxxxx/config )
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

smatch warnings:
drivers/usb/gadget/trace.c:26 gadget_configfs_group() warn: returning -1 instead of -ENOMEM is sloppy

vim +26 drivers/usb/gadget/trace.c

2f8f6deceeec1e Linyu Yuan 2022-03-30  16  static int gadget_configfs_group(char *group, struct config_item *item)
2f8f6deceeec1e Linyu Yuan 2022-03-30  17  {
2f8f6deceeec1e Linyu Yuan 2022-03-30  18  	struct config_item *parent;
2f8f6deceeec1e Linyu Yuan 2022-03-30  19  	char *tmpgroup;
2f8f6deceeec1e Linyu Yuan 2022-03-30  20  
2f8f6deceeec1e Linyu Yuan 2022-03-30  21  	if (!item)
2f8f6deceeec1e Linyu Yuan 2022-03-30  22  		return -1;
2f8f6deceeec1e Linyu Yuan 2022-03-30  23  
2f8f6deceeec1e Linyu Yuan 2022-03-30  24  	tmpgroup = kzalloc(GROUP_LEN, GFP_KERNEL);
2f8f6deceeec1e Linyu Yuan 2022-03-30  25  	if (!tmpgroup)
2f8f6deceeec1e Linyu Yuan 2022-03-30 @26  		return -1;

Better to use proper error codes.

2f8f6deceeec1e Linyu Yuan 2022-03-30  27  
2f8f6deceeec1e Linyu Yuan 2022-03-30  28  	for (parent = item->ci_parent; parent;
2f8f6deceeec1e Linyu Yuan 2022-03-30  29  			item = parent,parent = item->ci_parent) {
2f8f6deceeec1e Linyu Yuan 2022-03-30  30  		if (item->ci_type == &gadgets_type) {
2f8f6deceeec1e Linyu Yuan 2022-03-30  31  			kfree(tmpgroup);
2f8f6deceeec1e Linyu Yuan 2022-03-30  32  			return 0;
2f8f6deceeec1e Linyu Yuan 2022-03-30  33  		}
2f8f6deceeec1e Linyu Yuan 2022-03-30  34  
2f8f6deceeec1e Linyu Yuan 2022-03-30  35  		if (tmpgroup[0] == '\0')
2f8f6deceeec1e Linyu Yuan 2022-03-30  36  			snprintf(group, GROUP_LEN, "%s",
2f8f6deceeec1e Linyu Yuan 2022-03-30  37  					config_item_name(item));
2f8f6deceeec1e Linyu Yuan 2022-03-30  38  		else
2f8f6deceeec1e Linyu Yuan 2022-03-30  39  			snprintf(group, GROUP_LEN, "%s/%s",
2f8f6deceeec1e Linyu Yuan 2022-03-30  40  					config_item_name(item), tmpgroup);
2f8f6deceeec1e Linyu Yuan 2022-03-30  41  
2f8f6deceeec1e Linyu Yuan 2022-03-30  42  		strcpy(tmpgroup, group);
2f8f6deceeec1e Linyu Yuan 2022-03-30  43  	}
2f8f6deceeec1e Linyu Yuan 2022-03-30  44  
2f8f6deceeec1e Linyu Yuan 2022-03-30  45  	kfree(tmpgroup);
2f8f6deceeec1e Linyu Yuan 2022-03-30  46  	return -1;
2f8f6deceeec1e Linyu Yuan 2022-03-30  47  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp 
_______________________________________________
kbuild mailing list -- kbuild@xxxxxxxxxxxx
To unsubscribe send an email to kbuild-leave@xxxxxxxxxxxx




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux