* [ammarfaizi2-block:tglx/devel/printk 16/29] kernel/printk/printk.c:759 devkmsg_read() warn: variable dereferenced before check 'user' (see line 754)
@ 2022-09-13 9:14 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-09-13 9:14 UTC (permalink / raw)
To: kbuild, Thomas Gleixner
Cc: lkp, kbuild-all, Ammar Faizi, GNU/Weeb Mailing List, linux-kernel
tree: https://github.com/ammarfaizi2/linux-block tglx/devel/printk
head: f6339cd6dc7f812f822e86bd78d1edbf2bfc730b
commit: 4984141cc2064cdf4e4a122fa0d895bd93943e4e [16/29] printk: Use struct cons_text_buf
config: x86_64-randconfig-m001
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
smatch warnings:
kernel/printk/printk.c:759 devkmsg_read() warn: variable dereferenced before check 'user' (see line 754)
vim +/user +759 kernel/printk/printk.c
e11fea92e13fb9 kernel/printk.c Kay Sievers 2012-05-03 749 static ssize_t devkmsg_read(struct file *file, char __user *buf,
e11fea92e13fb9 kernel/printk.c Kay Sievers 2012-05-03 750 size_t count, loff_t *ppos)
e11fea92e13fb9 kernel/printk.c Kay Sievers 2012-05-03 751 {
e11fea92e13fb9 kernel/printk.c Kay Sievers 2012-05-03 752 struct devkmsg_user *user = file->private_data;
896fbe20b4e233 kernel/printk/printk.c John Ogness 2020-07-09 753 struct printk_record *r = &user->record;
4984141cc2064c kernel/printk/printk.c Thomas Gleixner 2022-09-03 @754 char *outbuf = user->txtbuf.ext_text;
^^^^^^
Dereference
4984141cc2064c kernel/printk/printk.c Thomas Gleixner 2022-09-03 755 const int maxlen = sizeof(user->txtbuf.ext_text);
e11fea92e13fb9 kernel/printk.c Kay Sievers 2012-05-03 756 size_t len;
e11fea92e13fb9 kernel/printk.c Kay Sievers 2012-05-03 757 ssize_t ret;
e11fea92e13fb9 kernel/printk.c Kay Sievers 2012-05-03 758
e11fea92e13fb9 kernel/printk.c Kay Sievers 2012-05-03 @759 if (!user)
^^^^^
Checked too late.
e11fea92e13fb9 kernel/printk.c Kay Sievers 2012-05-03 760 return -EBADF;
e11fea92e13fb9 kernel/printk.c Kay Sievers 2012-05-03 761
4a77a5a06ec66e kernel/printk.c Yuanhan Liu 2012-06-16 762 ret = mutex_lock_interruptible(&user->lock);
4a77a5a06ec66e kernel/printk.c Yuanhan Liu 2012-06-16 763 if (ret)
4a77a5a06ec66e kernel/printk.c Yuanhan Liu 2012-06-16 764 return ret;
de6fcbdb68b29b kernel/printk/printk.c Sergey Senozhatsky 2016-12-27 765
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-13 9:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-13 9:14 [ammarfaizi2-block:tglx/devel/printk 16/29] kernel/printk/printk.c:759 devkmsg_read() warn: variable dereferenced before check 'user' (see line 754) Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox