public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ubifs: fix uninitialized variable usage
@ 2024-11-15 22:26 Antonio Quartulli
  2024-11-16  2:02 ` Zhihao Cheng
  0 siblings, 1 reply; 3+ messages in thread
From: Antonio Quartulli @ 2024-11-15 22:26 UTC (permalink / raw)
  To: linux-mtd
  Cc: Antonio Quartulli, Richard Weinberger, Zhihao Cheng, linux-kernel

In ubifs_jnl_write_inode(), when an inode cannot be deleted
due to too many xattrs, err is passed to ubifs_ro_mode()
uninitialized, thus leading to bogus error reporting.

Fix this case by passing -EPERM, which is the same value that
ubifs_jnl_write_inode() is going to return to the caller.

This fixes 1 UNINIT issue reported by Coverity
Report: CID 1601860: Uninitialized scalar variable (UNINIT)

Cc: Richard Weinberger <richard@nod.at>
Cc: Zhihao Cheng <chengzhihao1@huawei.com>
Cc: linux-kernel@vger.kernel.org (open list)
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
 fs/ubifs/journal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index 8e98be642371..5eedf511880c 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -983,7 +983,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
 
 	if (kill_xattrs && ui->xattr_cnt > ubifs_xattr_max_cnt(c)) {
 		ubifs_err(c, "Cannot delete inode, it has too much xattrs!");
-		ubifs_ro_mode(c, err);
+		ubifs_ro_mode(c, -EPERM);
 		return -EPERM;
 	}
 
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ubifs: fix uninitialized variable usage
  2024-11-15 22:26 [PATCH] ubifs: fix uninitialized variable usage Antonio Quartulli
@ 2024-11-16  2:02 ` Zhihao Cheng
  2024-11-18 10:02   ` Antonio Quartulli
  0 siblings, 1 reply; 3+ messages in thread
From: Zhihao Cheng @ 2024-11-16  2:02 UTC (permalink / raw)
  To: Antonio Quartulli, linux-mtd; +Cc: Richard Weinberger, linux-kernel

在 2024/11/16 6:26, Antonio Quartulli 写道:
> In ubifs_jnl_write_inode(), when an inode cannot be deleted
> due to too many xattrs, err is passed to ubifs_ro_mode()
> uninitialized, thus leading to bogus error reporting.
> 
> Fix this case by passing -EPERM, which is the same value that
> ubifs_jnl_write_inode() is going to return to the caller.
> 
> This fixes 1 UNINIT issue reported by Coverity
> Report: CID 1601860: Uninitialized scalar variable (UNINIT)
> 
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Zhihao Cheng <chengzhihao1@huawei.com>
> Cc: linux-kernel@vger.kernel.org (open list)
> Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
> ---
>   fs/ubifs/journal.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Hi Antonio, thanks for the patch. Nathan has sent a patch to fix it.
https://lore.kernel.org/linux-mtd/b560f413-70f1-8ebb-7403-34591658ca86@huawei.com/T/#t
> 
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index 8e98be642371..5eedf511880c 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -983,7 +983,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
>   
>   	if (kill_xattrs && ui->xattr_cnt > ubifs_xattr_max_cnt(c)) {
>   		ubifs_err(c, "Cannot delete inode, it has too much xattrs!");
> -		ubifs_ro_mode(c, err);
> +		ubifs_ro_mode(c, -EPERM);
>   		return -EPERM;
>   	}
>   
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ubifs: fix uninitialized variable usage
  2024-11-16  2:02 ` Zhihao Cheng
@ 2024-11-18 10:02   ` Antonio Quartulli
  0 siblings, 0 replies; 3+ messages in thread
From: Antonio Quartulli @ 2024-11-18 10:02 UTC (permalink / raw)
  To: Zhihao Cheng, linux-mtd; +Cc: Richard Weinberger, linux-kernel

On 16/11/2024 03:02, Zhihao Cheng wrote:
> 在 2024/11/16 6:26, Antonio Quartulli 写道:
>> In ubifs_jnl_write_inode(), when an inode cannot be deleted
>> due to too many xattrs, err is passed to ubifs_ro_mode()
>> uninitialized, thus leading to bogus error reporting.
>>
>> Fix this case by passing -EPERM, which is the same value that
>> ubifs_jnl_write_inode() is going to return to the caller.
>>
>> This fixes 1 UNINIT issue reported by Coverity
>> Report: CID 1601860: Uninitialized scalar variable (UNINIT)
>>
>> Cc: Richard Weinberger <richard@nod.at>
>> Cc: Zhihao Cheng <chengzhihao1@huawei.com>
>> Cc: linux-kernel@vger.kernel.org (open list)
>> Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
>> ---
>>   fs/ubifs/journal.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Hi Antonio, thanks for the patch. Nathan has sent a patch to fix it.
> https://lore.kernel.org/linux-mtd/ 
> b560f413-70f1-8ebb-7403-34591658ca86@huawei.com/T/#t

Perfect!
Thanks for letting me know.

Regards,


-- 
Antonio Quartulli

CEO and Co-Founder
Mandelbit Srl
https://www.mandelbit.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-18 10:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 22:26 [PATCH] ubifs: fix uninitialized variable usage Antonio Quartulli
2024-11-16  2:02 ` Zhihao Cheng
2024-11-18 10:02   ` Antonio Quartulli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox