All of lore.kernel.org
 help / color / mirror / Atom feed
* [brauner:debugfs_namespaces 3/5] kernel/utsname.c:108 copy_utsname() error: 'new_ns' dereferencing possible ERR_PTR()
@ 2019-10-07  9:57 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2019-10-07  9:57 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 3566 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git debugfs_namespaces
head:   aef8406e30cf9b60c76e5de205fa77f3791e2c54
commit: fce9acb4ffd1b7b342c69f0c39d49835b7232414 [3/5] DEBUG

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
kernel/utsname.c:108 copy_utsname() error: 'new_ns' dereferencing possible ERR_PTR()

# https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?id=fce9acb4ffd1b7b342c69f0c39d49835b7232414
git remote add brauner https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git
git remote update brauner
git checkout fce9acb4ffd1b7b342c69f0c39d49835b7232414
vim +/new_ns +108 kernel/utsname.c

071df104f808b8 Serge E. Hallyn   2006-10-02   84  
4865ecf1315b45 Serge E. Hallyn   2006-10-02   85  /*
4865ecf1315b45 Serge E. Hallyn   2006-10-02   86   * Copy task tsk's utsname namespace, or clone it if flags
4865ecf1315b45 Serge E. Hallyn   2006-10-02   87   * specifies CLONE_NEWUTS.  In latter case, changes to the
4865ecf1315b45 Serge E. Hallyn   2006-10-02   88   * utsname of this process won't be seen by parent, and vice
4865ecf1315b45 Serge E. Hallyn   2006-10-02   89   * versa.
4865ecf1315b45 Serge E. Hallyn   2006-10-02   90   */
bb96a6f50be273 Serge E. Hallyn   2011-03-23   91  struct uts_namespace *copy_utsname(unsigned long flags,
bcf58e725ddc45 Eric W. Biederman 2012-07-26   92  	struct user_namespace *user_ns, struct uts_namespace *old_ns)
4865ecf1315b45 Serge E. Hallyn   2006-10-02   93  {
071df104f808b8 Serge E. Hallyn   2006-10-02   94  	struct uts_namespace *new_ns;
fce9acb4ffd1b7 Christian Brauner 2019-10-02   95  	char name[50];
4865ecf1315b45 Serge E. Hallyn   2006-10-02   96  
e3222c4ecc649c Badari Pulavarty  2007-05-08   97  	BUG_ON(!old_ns);
4865ecf1315b45 Serge E. Hallyn   2006-10-02   98  	get_uts_ns(old_ns);
4865ecf1315b45 Serge E. Hallyn   2006-10-02   99  
071df104f808b8 Serge E. Hallyn   2006-10-02  100  	if (!(flags & CLONE_NEWUTS))
e3222c4ecc649c Badari Pulavarty  2007-05-08  101  		return old_ns;
071df104f808b8 Serge E. Hallyn   2006-10-02  102  
bcf58e725ddc45 Eric W. Biederman 2012-07-26  103  	new_ns = clone_uts_ns(user_ns, old_ns);
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This isn't checked for errors

071df104f808b8 Serge E. Hallyn   2006-10-02  104  
071df104f808b8 Serge E. Hallyn   2006-10-02  105  	put_uts_ns(old_ns);
fce9acb4ffd1b7 Christian Brauner 2019-10-02  106  
fce9acb4ffd1b7 Christian Brauner 2019-10-02  107  	if (uts_debugfs) {
fce9acb4ffd1b7 Christian Brauner 2019-10-02 @108  		snprintf(name, 50, "uts:[%u]", new_ns->ns.inum);
                                                                                               ^^^^^^^^^^^^^^^
Oops

fce9acb4ffd1b7 Christian Brauner 2019-10-02  109  		new_ns->ns.debugfs = debugfs_create_file(name, 0600, uts_debugfs,
fce9acb4ffd1b7 Christian Brauner 2019-10-02  110  					    &new_ns->ns, &ns_file_operations);
fce9acb4ffd1b7 Christian Brauner 2019-10-02  111  	}
fce9acb4ffd1b7 Christian Brauner 2019-10-02  112  
e3222c4ecc649c Badari Pulavarty  2007-05-08  113  	return new_ns;
4865ecf1315b45 Serge E. Hallyn   2006-10-02  114  }
4865ecf1315b45 Serge E. Hallyn   2006-10-02  115  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <20191007100530.xnpvxrhbl77yabjr@wittgenstein>]

end of thread, other threads:[~2019-10-07 10:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-07  9:57 [brauner:debugfs_namespaces 3/5] kernel/utsname.c:108 copy_utsname() error: 'new_ns' dereferencing possible ERR_PTR() Dan Carpenter
2019-10-07  9:57 ` Dan Carpenter
     [not found] <20191007100530.xnpvxrhbl77yabjr@wittgenstein>
2019-10-07 10:26 ` Dan Carpenter
2019-10-07 10:26   ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.