Removing the "if (IS_ERR(dir)) dir = NULL;" check only works if we adjust the remaining code to not rely on it being NULL. Check IS_ERR_OR_NULL() before attempting to dereference it. I'm not actually entirely sure this fixes the syzbot crash as the kernel config indicates that they do have DEBUG_FS in the kernel, but this is what I found when looking there.
Unified · Split
| @@ -142,7 +142,7 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev, · 141 unmodified lines | |||
| 142 | if (result) | 142 | if (result) |
| 143 | return result; | 143 | return result; |
| 144 | 144 | ||
| 145 | if (rdev->wiphy.debugfsdir) | 145 | if (!IS_ERR_OR_NULL(rdev->wiphy.debugfsdir)) |
| 146 | debugfs_rename(rdev->wiphy.debugfsdir->d_parent, | 146 | debugfs_rename(rdev->wiphy.debugfsdir->d_parent, |
| 147 | rdev->wiphy.debugfsdir, | 147 | rdev->wiphy.debugfsdir, |
| 148 | rdev->wiphy.debugfsdir->d_parent, newname); | 148 | rdev->wiphy.debugfsdir->d_parent, newname); |