[PATCH 12/33] fsi: core: Allow cfam device type aliases
Dan Carpenter
dan.carpenter at linaro.org
Tue Feb 20 19:31:03 AEDT 2024
Hi Eddie,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Eddie-James/dt-bindings-clock-ast2600-Add-FSI-clock/20240216-061934
base: git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link: https://lore.kernel.org/r/20240215220759.976998-13-eajames%40linux.ibm.com
patch subject: [PATCH 12/33] fsi: core: Allow cfam device type aliases
config: arm64-randconfig-r081-20240216 (https://download.01.org/0day-ci/archive/20240220/202402201532.dvENQrDs-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 36adfec155de366d722f2bac8ff9162289dcf06c)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp at intel.com>
| Reported-by: Dan Carpenter <dan.carpenter at linaro.org>
| Closes: https://lore.kernel.org/r/202402201532.dvENQrDs-lkp@intel.com/
smatch warnings:
drivers/fsi/fsi-core.c:919 __fsi_get_new_minor() error: testing array offset 'type' after use.
vim +/type +919 drivers/fsi/fsi-core.c
3f4ac5b0b27f16 Eddie James 2024-02-15 894 static int __fsi_get_new_minor(struct fsi_slave *slave, struct device_node *np,
3f4ac5b0b27f16 Eddie James 2024-02-15 895 enum fsi_dev_type type, dev_t *out_dev, int *out_index)
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 896 {
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 897 int cid = slave->chip_id;
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 898 int id;
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 899
3f4ac5b0b27f16 Eddie James 2024-02-15 900 if (np) {
3f4ac5b0b27f16 Eddie James 2024-02-15 901 int aid = of_alias_get_id(np, fsi_dev_type_names[type]);
^^^^
if type >= 4 we are in trouble
3f4ac5b0b27f16 Eddie James 2024-02-15 902
3f4ac5b0b27f16 Eddie James 2024-02-15 903 if (aid >= 0) {
3f4ac5b0b27f16 Eddie James 2024-02-15 904 /* Use the same scheme as the legacy numbers. */
3f4ac5b0b27f16 Eddie James 2024-02-15 905 id = (aid << 2) | type;
3f4ac5b0b27f16 Eddie James 2024-02-15 906 id = ida_alloc_range(&fsi_minor_ida, id, id, GFP_KERNEL);
3f4ac5b0b27f16 Eddie James 2024-02-15 907 if (id >= 0) {
3f4ac5b0b27f16 Eddie James 2024-02-15 908 *out_index = aid;
3f4ac5b0b27f16 Eddie James 2024-02-15 909 *out_dev = fsi_base_dev + id;
3f4ac5b0b27f16 Eddie James 2024-02-15 910 return 0;
3f4ac5b0b27f16 Eddie James 2024-02-15 911 }
3f4ac5b0b27f16 Eddie James 2024-02-15 912
3f4ac5b0b27f16 Eddie James 2024-02-15 913 if (id != -ENOSPC)
3f4ac5b0b27f16 Eddie James 2024-02-15 914 return id;
3f4ac5b0b27f16 Eddie James 2024-02-15 915 }
3f4ac5b0b27f16 Eddie James 2024-02-15 916 }
3f4ac5b0b27f16 Eddie James 2024-02-15 917
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 918 /* Check if we qualify for legacy numbering */
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 @919 if (cid >= 0 && cid < 16 && type < 4) {
^^^^^^^^
checked too late
641511bfcc5e01 Eddie James 2023-06-12 920 /*
641511bfcc5e01 Eddie James 2023-06-12 921 * Try reserving the legacy number, which has 0 - 0x3f reserved
641511bfcc5e01 Eddie James 2023-06-12 922 * in the ida range. cid goes up to 0xf and type contains two
641511bfcc5e01 Eddie James 2023-06-12 923 * bits, so construct the id with the below two bit shift.
641511bfcc5e01 Eddie James 2023-06-12 924 */
641511bfcc5e01 Eddie James 2023-06-12 925 id = (cid << 2) | type;
85f4e899de32ba Eddie James 2023-06-12 926 id = ida_alloc_range(&fsi_minor_ida, id, id, GFP_KERNEL);
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 927 if (id >= 0) {
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 928 *out_index = fsi_adjust_index(cid);
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 929 *out_dev = fsi_base_dev + id;
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 930 return 0;
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 931 }
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 932 /* Other failure */
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 933 if (id != -ENOSPC)
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 934 return id;
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 935 /* Fallback to non-legacy allocation */
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 936 }
85f4e899de32ba Eddie James 2023-06-12 937 id = ida_alloc_range(&fsi_minor_ida, FSI_CHAR_LEGACY_TOP,
85f4e899de32ba Eddie James 2023-06-12 938 FSI_CHAR_MAX_DEVICES - 1, GFP_KERNEL);
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 939 if (id < 0)
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 940 return id;
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 941 *out_index = fsi_adjust_index(id);
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 942 *out_dev = fsi_base_dev + id;
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 943 return 0;
0ab5fe5374743d Benjamin Herrenschmidt 2018-06-20 944 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
More information about the linux-fsi
mailing list