lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202204060533.8RYu7zFU-lkp@intel.com>
Date:   Wed, 6 Apr 2022 09:05:19 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Alison Schofield <alison.schofield@...el.com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        Alison Schofield <alison.schofield@...el.com>,
        Vishal Verma <vishal.l.verma@...el.com>,
        Ira Weiny <ira.weiny@...el.com>,
        Ben Widawsky <ben.widawsky@...el.com>,
        Dan Williams <dan.j.williams@...el.com>,
        linux-kernel@...r.kernel.org
Subject: [cxl:pending 3/13] drivers/cxl/core/mbox.c:223 cxl_mbox_cmd_ctor()
 warn: passing zero to 'PTR_ERR'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git pending
head:   7dc1d11d7abae52aada5340fb98885f0ddbb7c37
commit: be0d0ce77aa3b93c40e2f72bbcab5df883bc0cb6 [3/13] cxl/mbox: Move build of user mailbox cmd to a helper functions
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220406/202204060533.8RYu7zFU-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>

smatch warnings:
drivers/cxl/core/mbox.c:223 cxl_mbox_cmd_ctor() warn: passing zero to 'PTR_ERR'
drivers/cxl/core/mbox.c:227 cxl_mbox_cmd_ctor() warn: unsigned 'out_size' is never less than zero.

vim +/PTR_ERR +223 drivers/cxl/core/mbox.c

be0d0ce77aa3b93 Alison Schofield 2022-03-30  210  static int cxl_mbox_cmd_ctor(struct cxl_mbox_cmd *mbox,
be0d0ce77aa3b93 Alison Schofield 2022-03-30  211  			     struct cxl_dev_state *cxlds, u16 opcode,
be0d0ce77aa3b93 Alison Schofield 2022-03-30  212  			     size_t in_size, size_t out_size, u64 in_payload)
be0d0ce77aa3b93 Alison Schofield 2022-03-30  213  {
be0d0ce77aa3b93 Alison Schofield 2022-03-30  214  	*mbox = (struct cxl_mbox_cmd) {
be0d0ce77aa3b93 Alison Schofield 2022-03-30  215  		.opcode = opcode,
be0d0ce77aa3b93 Alison Schofield 2022-03-30  216  		.size_in = in_size,
be0d0ce77aa3b93 Alison Schofield 2022-03-30  217  	};
be0d0ce77aa3b93 Alison Schofield 2022-03-30  218  
be0d0ce77aa3b93 Alison Schofield 2022-03-30  219  	if (in_size) {
be0d0ce77aa3b93 Alison Schofield 2022-03-30  220  		mbox->payload_in = vmemdup_user(u64_to_user_ptr(in_payload),
be0d0ce77aa3b93 Alison Schofield 2022-03-30  221  						in_size);
be0d0ce77aa3b93 Alison Schofield 2022-03-30  222  		if (!mbox->payload_in)
be0d0ce77aa3b93 Alison Schofield 2022-03-30 @223  			return PTR_ERR(mbox->payload_in);

This PTR_ERR(NULL) is success, return -ENOMEM was intended.

be0d0ce77aa3b93 Alison Schofield 2022-03-30  224  	}
be0d0ce77aa3b93 Alison Schofield 2022-03-30  225  
be0d0ce77aa3b93 Alison Schofield 2022-03-30  226  	/* Prepare to handle a full payload for variable sized output */
be0d0ce77aa3b93 Alison Schofield 2022-03-30 @227  	if (out_size < 0)
                                                            ^^^^^^^^^^^^
Unsigned < 0

be0d0ce77aa3b93 Alison Schofield 2022-03-30  228  		mbox->size_out = cxlds->payload_size;
be0d0ce77aa3b93 Alison Schofield 2022-03-30  229  	else
be0d0ce77aa3b93 Alison Schofield 2022-03-30  230  		mbox->size_out = out_size;
be0d0ce77aa3b93 Alison Schofield 2022-03-30  231  
be0d0ce77aa3b93 Alison Schofield 2022-03-30  232  	if (mbox->size_out) {
be0d0ce77aa3b93 Alison Schofield 2022-03-30  233  		mbox->payload_out = kvzalloc(mbox->size_out, GFP_KERNEL);
be0d0ce77aa3b93 Alison Schofield 2022-03-30  234  		if (!mbox->payload_out) {
be0d0ce77aa3b93 Alison Schofield 2022-03-30  235  			kvfree(mbox->payload_in);
be0d0ce77aa3b93 Alison Schofield 2022-03-30  236  			return -ENOMEM;
be0d0ce77aa3b93 Alison Schofield 2022-03-30  237  		}
be0d0ce77aa3b93 Alison Schofield 2022-03-30  238  	}
be0d0ce77aa3b93 Alison Schofield 2022-03-30  239  	return 0;
be0d0ce77aa3b93 Alison Schofield 2022-03-30  240  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ