[bug report] ALSA: hda/tas2781: Ignore SUBSYS_ID not found for tas2563 projects

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



Hello Baojun Xu,

Commit 6a451e2c5c03 ("ALSA: hda/tas2781: Ignore SUBSYS_ID not found
for tas2563 projects") from Dec 30, 2024 (linux-next), leads to the
following Smatch static checker warning:

	sound/pci/hda/tas2781_hda_i2c.c:146 tas2781_read_acpi()
	warn: strncmp() with weird length: 7 vs 8

sound/pci/hda/tas2781_hda_i2c.c
    121 static int tas2781_read_acpi(struct tasdevice_priv *p, const char *hid)
    122 {
    123         struct acpi_device *adev;
    124         struct device *physdev;
    125         LIST_HEAD(resources);
    126         const char *sub;
    127         uint32_t subid;
    128         int ret;
    129 
    130         adev = acpi_dev_get_first_match_dev(hid, NULL, -1);
    131         if (!adev) {
    132                 dev_err(p->dev,
    133                         "Failed to find an ACPI device for %s\n", hid);
    134                 return -ENODEV;
    135         }
    136 
    137         physdev = get_device(acpi_get_first_physical_node(adev));
    138         ret = acpi_dev_get_resources(adev, &resources, tas2781_get_i2c_res, p);
    139         if (ret < 0) {
    140                 dev_err(p->dev, "Failed to get ACPI resource.\n");
    141                 goto err;
    142         }
    143         sub = acpi_get_subsystem_id(ACPI_HANDLE(physdev));
    144         if (IS_ERR(sub)) {
    145                 /* No subsys id in older tas2563 projects. */
--> 146                 if (!strncmp(hid, "INT8866", sizeof("INT8866")))


What is the point of using strncmp() here?  It looks like potentially
the intention was to check:

	if (!strncmp(hid, "INT8866", sizeof("INT8866") - 1))

This code is 100% equivalent to:

	if (!strcmp(hid, "INT8866"))
		goto end_2563;

    147                         goto end_2563;
    148                 dev_err(p->dev, "Failed to get SUBSYS ID.\n");
    149                 ret = PTR_ERR(sub);
    150                 goto err;
    151         }
    152         /* Speaker id was needed for ASUS projects. */
    153         ret = kstrtou32(sub, 16, &subid);
    154         if (!ret && upper_16_bits(subid) == PCI_VENDOR_ID_ASUSTEK) {
    155                 ret = devm_acpi_dev_add_driver_gpios(p->dev,
    156                         tas2781_speaker_id_gpios);
    157                 if (ret < 0)
    158                         dev_err(p->dev, "Failed to add driver gpio %d.\n",
    159                                 ret);
    160                 p->speaker_id = devm_gpiod_get(p->dev, "speakerid", GPIOD_IN);
    161                 if (IS_ERR(p->speaker_id)) {
    162                         dev_err(p->dev, "Failed to get Speaker id.\n");
    163                         ret = PTR_ERR(p->speaker_id);
    164                         goto err;
    165                 }
    166         } else {
    167                 p->speaker_id = NULL;
    168         }
    169 
    170 end_2563:
    171         acpi_dev_free_resource_list(&resources);
    172         strscpy(p->dev_name, hid, sizeof(p->dev_name));
    173         put_device(physdev);
    174         acpi_dev_put(adev);
    175 
    176         return 0;
    177 
    178 err:
    179         dev_err(p->dev, "read acpi error, ret: %d\n", ret);
    180         put_device(physdev);
    181         acpi_dev_put(adev);
    182 
    183         return ret;
    184 }

regards,
dan carpenter




[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux