* [bug report] HID: haptic: initialize haptic device
@ 2025-09-18 7:18 Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2025-09-18 7:18 UTC (permalink / raw)
To: Angela Czubak; +Cc: linux-input
Hello Angela Czubak,
Commit 344ff3584957 ("HID: haptic: initialize haptic device") from
Aug 18, 2025 (linux-next), leads to the following Smatch static
checker warning:
drivers/hid/hid-haptic.c:528 hid_haptic_init()
warn: missing error code here? '_dev_err()' failed. 'ret' = '0'
drivers/hid/hid-haptic.c
518 }
519
520 ff = dev->ff;
521 ff->private = haptic;
522 ff->upload = hid_haptic_upload_effect;
523 ff->playback = hid_haptic_playback;
524 ff->erase = hid_haptic_erase;
525 ff->destroy = hid_haptic_destroy;
526 if (!try_module_get(THIS_MODULE)) {
527 dev_err(&hdev->dev, "Failed to increase module count.\n");
--> 528 goto input_free;
Missing error code. I think we're trying to pump the module count so
this module is unloadable. That's a discouraged thing so the
__module_get() function has a double underscore. But here we're kind
of dressing it up so it looks like we're doing a legit module count
bump of a different module that we rely on (instead of THIS_MODULE). We
should just use __module_get() because it's more honest and remove the
check.
529 }
530 if (!get_device(&hdev->dev)) {
531 dev_err(&hdev->dev, "Failed to get hdev device.\n");
532 module_put(THIS_MODULE);
533 goto input_free;
Missing error code, but get_device() can't really fail here. Just remove
the check.
534 }
535 return 0;
536
537 input_free:
538 input_ff_destroy(dev);
539 /* Do not let double free happen, input_ff_destroy will call
540 * hid_haptic_destroy.
541 */
542 *haptic_ptr = NULL;
543 /* Restore dev flush and event */
544 dev->flush = flush;
545 dev->event = event;
546 return ret;
547 stop_buffer_free:
548 kfree(haptic->stop_effect.report_buf);
549 haptic->stop_effect.report_buf = NULL;
550 buffer_free:
551 while (--r >= 0)
552 kfree(haptic->effect[r].report_buf);
553 kfree(haptic->effect);
554 haptic->effect = NULL;
555 output_queue:
556 destroy_workqueue(haptic->wq);
557 haptic->wq = NULL;
558 duration_map:
559 kfree(haptic->duration_map);
560 haptic->duration_map = NULL;
561 usage_map:
562 kfree(haptic->hid_usage_map);
563 haptic->hid_usage_map = NULL;
564 exit:
565 return ret;
566 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread* [bug report] HID: haptic: initialize haptic device
@ 2025-09-18 9:46 Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2025-09-18 9:46 UTC (permalink / raw)
To: Angela Czubak; +Cc: linux-input
Hello Angela Czubak,
Commit 344ff3584957 ("HID: haptic: initialize haptic device") from
Aug 18, 2025 (linux-next), leads to the following Smatch static
checker warning:
drivers/hid/hid-haptic.c:193 fill_effect_buf()
error: uninitialized symbol 'value'.
drivers/hid/hid-haptic.c
147 static void fill_effect_buf(struct hid_haptic_device *haptic,
148 struct ff_haptic_effect *effect,
149 struct hid_haptic_effect *haptic_effect,
150 int waveform_ordinal)
151 {
152 struct hid_report *rep = haptic->manual_trigger_report;
153 struct hid_usage *usage;
154 struct hid_field *field;
155 s32 value;
156 int i, j;
157 u8 *buf = haptic_effect->report_buf;
158
159 mutex_lock(&haptic->manual_trigger_mutex);
160 for (i = 0; i < rep->maxfield; i++) {
161 field = rep->field[i];
162 /* Ignore if report count is out of bounds. */
163 if (field->report_count < 1)
164 continue;
165
166 for (j = 0; j < field->maxusage; j++) {
167 usage = &field->usage[j];
168
169 switch (usage->hid) {
170 case HID_HP_INTENSITY:
171 if (effect->intensity > 100) {
172 value = field->logical_maximum;
173 } else {
174 value = field->logical_minimum +
175 effect->intensity *
176 (field->logical_maximum -
177 field->logical_minimum) / 100;
178 }
179 break;
180 case HID_HP_REPEATCOUNT:
181 value = effect->repeat_count;
182 break;
183 case HID_HP_RETRIGGERPERIOD:
184 value = effect->retrigger_period;
185 break;
186 case HID_HP_MANUALTRIGGER:
187 value = waveform_ordinal;
188 break;
189 default:
190 break;
value is not set on the default path.
191 }
192
--> 193 field->value[j] = value;
194 }
195 }
196
197 hid_output_report(rep, buf);
198 mutex_unlock(&haptic->manual_trigger_mutex);
199 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-18 9:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 7:18 [bug report] HID: haptic: initialize haptic device Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2025-09-18 9:46 Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox