public inbox for [email protected]
 help / color / mirror / Atom feed
From: Dan Carpenter <[email protected]>
To: [email protected], Thomas Gleixner <[email protected]>
Cc: [email protected], [email protected],
	Ammar Faizi <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>,
	[email protected]
Subject: [ammarfaizi2-block:tglx/devel/printk 16/29] kernel/printk/printk.c:759 devkmsg_read() warn: variable dereferenced before check 'user' (see line 754)
Date: Tue, 13 Sep 2022 12:14:46 +0300	[thread overview]
Message-ID: <[email protected]> (raw)

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  


                 reply	other threads:[~2022-09-13  9:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox