@@ -152,6 +152,12 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
152
152
ui -> data_len = size ;
153
153
154
154
mutex_lock (& host_ui -> ui_mutex );
155
+
156
+ if (!host -> i_nlink ) {
157
+ err = - ENOENT ;
158
+ goto out_noent ;
159
+ }
160
+
155
161
host -> i_ctime = current_time (host );
156
162
host_ui -> xattr_cnt += 1 ;
157
163
host_ui -> xattr_size += CALC_DENT_SIZE (fname_len (nm ));
@@ -184,6 +190,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
184
190
host_ui -> xattr_size -= CALC_XATTR_BYTES (size );
185
191
host_ui -> xattr_names -= fname_len (nm );
186
192
host_ui -> flags &= ~UBIFS_CRYPT_FL ;
193
+ out_noent :
187
194
mutex_unlock (& host_ui -> ui_mutex );
188
195
out_free :
189
196
make_bad_inode (inode );
@@ -235,6 +242,12 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
235
242
mutex_unlock (& ui -> ui_mutex );
236
243
237
244
mutex_lock (& host_ui -> ui_mutex );
245
+
246
+ if (!host -> i_nlink ) {
247
+ err = - ENOENT ;
248
+ goto out_noent ;
249
+ }
250
+
238
251
host -> i_ctime = current_time (host );
239
252
host_ui -> xattr_size -= CALC_XATTR_BYTES (old_size );
240
253
host_ui -> xattr_size += CALC_XATTR_BYTES (size );
@@ -256,6 +269,7 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
256
269
out_cancel :
257
270
host_ui -> xattr_size -= CALC_XATTR_BYTES (size );
258
271
host_ui -> xattr_size += CALC_XATTR_BYTES (old_size );
272
+ out_noent :
259
273
mutex_unlock (& host_ui -> ui_mutex );
260
274
make_bad_inode (inode );
261
275
out_free :
@@ -482,6 +496,12 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host,
482
496
return err ;
483
497
484
498
mutex_lock (& host_ui -> ui_mutex );
499
+
500
+ if (!host -> i_nlink ) {
501
+ err = - ENOENT ;
502
+ goto out_noent ;
503
+ }
504
+
485
505
host -> i_ctime = current_time (host );
486
506
host_ui -> xattr_cnt -= 1 ;
487
507
host_ui -> xattr_size -= CALC_DENT_SIZE (fname_len (nm ));
@@ -501,6 +521,7 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host,
501
521
host_ui -> xattr_size += CALC_DENT_SIZE (fname_len (nm ));
502
522
host_ui -> xattr_size += CALC_XATTR_BYTES (ui -> data_len );
503
523
host_ui -> xattr_names += fname_len (nm );
524
+ out_noent :
504
525
mutex_unlock (& host_ui -> ui_mutex );
505
526
ubifs_release_budget (c , & req );
506
527
make_bad_inode (inode );
@@ -540,6 +561,9 @@ static int ubifs_xattr_remove(struct inode *host, const char *name)
540
561
541
562
ubifs_assert (inode_is_locked (host ));
542
563
564
+ if (!host -> i_nlink )
565
+ return - ENOENT ;
566
+
543
567
if (fname_len (& nm ) > UBIFS_MAX_NLEN )
544
568
return - ENAMETOOLONG ;
545
569
0 commit comments