drivers/input/joystick/fsia6b.c:152:57: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32
From: kernel test robot
Date: Wed Jan 01 2025 - 14:25:34 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: ccb98ccef0e543c2bd4ef1a72270461957f3d8d0
commit: 5d4b45a1dd7b00feab57624035dcdbc1bab2e0f8 Input: add support for the FlySky FS-iA6B RC receiver
date: 5 years ago
config: x86_64-randconfig-a013-20211029 (https://download.01.org/0day-ci/archive/20250102/202501020303.1WtxWWTu-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250102/202501020303.1WtxWWTu-lkp@xxxxxxxxx/reproduce)
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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501020303.1WtxWWTu-lkp@xxxxxxxxx/
All warnings (new ones prefixed by >>):
drivers/input/joystick/fsia6b.c: In function 'fsia6b_serio_connect':
>> drivers/input/joystick/fsia6b.c:152:57: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
152 | snprintf(fsia6b->phys, sizeof(fsia6b->phys), "%s/input0", serio->phys);
| ^~~~~~~
drivers/input/joystick/fsia6b.c:152:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
152 | snprintf(fsia6b->phys, sizeof(fsia6b->phys), "%s/input0", serio->phys);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +152 drivers/input/joystick/fsia6b.c
126
127 static int fsia6b_serio_connect(struct serio *serio, struct serio_driver *drv)
128 {
129 struct fsia6b *fsia6b;
130 struct input_dev *input_dev;
131 int err;
132 int i, j;
133 int sw_id = 0;
134
135 fsia6b = kzalloc(sizeof(*fsia6b), GFP_KERNEL);
136 if (!fsia6b)
137 return -ENOMEM;
138
139 fsia6b->packet.ibuf = 0;
140 fsia6b->packet.offset = 0;
141 fsia6b->packet.state = SYNC;
142
143 serio_set_drvdata(serio, fsia6b);
144
145 input_dev = input_allocate_device();
146 if (!input_dev) {
147 err = -ENOMEM;
148 goto fail1;
149 }
150 fsia6b->dev = input_dev;
151
> 152 snprintf(fsia6b->phys, sizeof(fsia6b->phys), "%s/input0", serio->phys);
153
154 input_dev->name = DRIVER_DESC;
155 input_dev->phys = fsia6b->phys;
156 input_dev->id.bustype = BUS_RS232;
157 input_dev->id.vendor = SERIO_FSIA6B;
158 input_dev->id.product = serio->id.id;
159 input_dev->id.version = 0x0100;
160 input_dev->dev.parent = &serio->dev;
161
162 for (i = 0; i < IBUS_SERVO_COUNT; i++)
163 input_set_abs_params(input_dev, fsia6b_axes[i],
164 1000, 2000, 2, 2);
165
166 /* Register switch configuration */
167 for (i = 0; i < IBUS_SERVO_COUNT; i++) {
168 if (switch_config[i] < '0' || switch_config[i] > '3') {
169 dev_err(&fsia6b->dev->dev,
170 "Invalid switch configuration supplied for fsia6b.\n");
171 err = -EINVAL;
172 goto fail2;
173 }
174
175 for (j = '1'; j <= switch_config[i]; j++) {
176 input_set_capability(input_dev, EV_KEY, BTN_0 + sw_id);
177 sw_id++;
178 }
179 }
180
181 err = serio_open(serio, drv);
182 if (err)
183 goto fail2;
184
185 err = input_register_device(fsia6b->dev);
186 if (err)
187 goto fail3;
188
189 return 0;
190
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki