Skip to contentSkip to conversation

ath11k: add debugfs for TWT debug calls

bug report Dan Carpenter 3 participants 3 messages Mar 1, 2022 – Apr 7, 2022 Qualcomm Atheros ATH11K wireless driver

lore
Share & tools
lore
#0 lore raw

Hello John Crispin,

The patch fe98a6137d03: "ath11k: add debugfs for TWT debug calls" from Jan 31, 2022, leads to the following Smatch static checker warning:

	drivers/net/wireless/ath/ath11k/debugfs.c:1642 ath11k_debugfs_add_interface()
	warn: 'arvif->debugfs_twt' is an error pointer or valid

drivers/net/wireless/ath/ath11k/debugfs.c

    1637 int ath11k_debugfs_add_interface(struct ath11k_vif *arvif)
    1638 {
    1639         if (arvif->vif->type == NL80211_IFTYPE_AP && !arvif->debugfs_twt) {
    1640                 arvif->debugfs_twt = debugfs_create_dir("twt",
    1641                                                         arvif->vif->debugfs_dir);
--> 1642                 if (!arvif->debugfs_twt || IS_ERR(arvif->debugfs_twt)) {
    1643                         ath11k_warn(arvif->ar->ab,
    1644                                     "failed to create directory %p\n",
    1645                                     arvif->debugfs_twt);

The debugfs_create_dir() function never returns NULL. It's generally not supposed to checked for errors. This code here looks like a layering violation because it's trying to check if debugfs is already registered. But the clean up code just unregisters on the first call. Should it be ref counted or can the !arvif->debugfs_twt check be removed?

Also if the user deliberately disabled debugfs then this prints an error message.

    1646                         arvif->debugfs_twt = NULL;
    1647                         return -1;
    1648                 }
    1649 
    1650                 debugfs_create_file("add_dialog", 0200, arvif->debugfs_twt,
    1651                                     arvif, &ath11k_fops_twt_add_dialog);
    1652 
    1653                 debugfs_create_file("del_dialog", 0200, arvif->debugfs_twt,
    1654                                     arvif, &ath11k_fops_twt_del_dialog);
    1655 
    1656                 debugfs_create_file("pause_dialog", 0200, arvif->debugfs_twt,
    1657                                     arvif, &ath11k_fops_twt_pause_dialog);
    1658 
    1659                 debugfs_create_file("resume_dialog", 0200, arvif->debugfs_twt,
    1660                                     arvif, &ath11k_fops_twt_resume_dialog);
    1661         }
    1662         return 0;
    1663 }

regards,
dan carpenter

Signature · 3 lines
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#1 lore raw

+ aloka

Quoted 27 lines · Dan Carpenter

Hello John Crispin,

The patch fe98a6137d03: "ath11k: add debugfs for TWT debug calls" from Jan 31, 2022, leads to the following Smatch static checker warning:

	drivers/net/wireless/ath/ath11k/debugfs.c:1642 ath11k_debugfs_add_interface()
	warn: 'arvif->debugfs_twt' is an error pointer or valid

drivers/net/wireless/ath/ath11k/debugfs.c

    1637 int ath11k_debugfs_add_interface(struct ath11k_vif *arvif)
    1638 {
    1639         if (arvif->vif->type == NL80211_IFTYPE_AP && !arvif->debugfs_twt) {
    1640                 arvif->debugfs_twt = debugfs_create_dir("twt",
    1641                                                         arvif->vif->debugfs_dir);
--> 1642                 if (!arvif->debugfs_twt || IS_ERR(arvif->debugfs_twt)) {
    1643                         ath11k_warn(arvif->ar->ab,
    1644                                     "failed to create directory %p\n",
    1645                                     arvif->debugfs_twt);

The debugfs_create_dir() function never returns NULL. It's generally not supposed to checked for errors. This code here looks like a layering violation because it's trying to check if debugfs is already registered. But the clean up code just unregisters on the first call. Should it be ref counted or can the !arvif->debugfs_twt check be removed?

Quoted 5 lines

Also if the user deliberately disabled debugfs then this prints an error message.

    1646                         arvif->debugfs_twt = NULL;
    1647                         return -1;

Please also use proper error values, not -1.

Quoted 8 lines
    1648                 }
    1649 
    1650                 debugfs_create_file("add_dialog", 0200, arvif->debugfs_twt,
    1651                                     arvif, &ath11k_fops_twt_add_dialog);
    1652 
    1653                 debugfs_create_file("del_dialog", 0200, arvif->debugfs_twt,
    1654                                     arvif, &ath11k_fops_twt_del_dialog);
    1655 
Quoted 8 lines
    1656                 debugfs_create_file("pause_dialog", 0200, arvif->debugfs_twt,
    1657                                     arvif, &ath11k_fops_twt_pause_dialog);
    1658 
    1659                 debugfs_create_file("resume_dialog", 0200, arvif->debugfs_twt,
    1660                                     arvif, &ath11k_fops_twt_resume_dialog);
    1661         }
    1662         return 0;
    1663 }

Aloka, you submitted this patch. Please take a look and fix the issues.

Signature · 8 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#2 lore raw
Quoted 4 lines · Kalle Valo

+ aloka

Dan Carpenter <[email protected]> writes:

Quoted 9 lines
Quoted 6 lines

Hello John Crispin,

The patch fe98a6137d03: "ath11k: add debugfs for TWT debug calls" from Jan 31, 2022, leads to the following Smatch static checker warning:

Aloka, you submitted this patch. Please take a look and fix the issues.

Will send a fix. Thanks.

Signature · 3 lines
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k