inotify_add_watch explictly frees the unused inode mark, but it can just use the generic code. Just do that.
Unified · Split
| @@ -578,16 +578,13 @@ retry: · 577 unmodified lines | ||
| 578 | 578 | /* return the watch descriptor for this new entry */ |
| 579 | 579 | ret = tmp_ientry->wd; |
| 580 | 580 | |
| 581 | − /* match the ref from fsnotify_init_markentry() */ | |
| 582 | − fsnotify_put_mark(&tmp_ientry->fsn_entry); | |
| 583 | − | |
| 584 | 581 | /* if this mark added a new event update the group mask */ |
| 585 | 582 | if (mask & ~group->mask) |
| 586 | 583 | fsnotify_recalc_group_mask(group); |
| 587 | 584 | |
| 588 | 585 | out_err: |
| 589 | − if (ret < 0) | |
| 590 | − kmem_cache_free(inotify_inode_mark_cachep, tmp_ientry); | |
| 586 | + /* match the ref from fsnotify_init_markentry() */ | |
| 587 | + fsnotify_put_mark(&tmp_ientry->fsn_entry); | |
| 591 | 588 | |
| 592 | 589 | return ret; |
| 593 | 590 | } |