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: <36170c8-2d89-6c70-7e1d-1b52e950c7a1@inria.fr>
Date: Fri, 19 Jan 2024 18:29:21 +0100 (CET)
From: Julia Lawall <julia.lawall@...ia.fr>
To: Javier Carrasco <javier.carrasco@...fvision.net>
cc: Heikki Krogerus <heikki.krogerus@...ux.intel.com>, 
    linux-kernel@...r.kernel.org, oe-kbuild-all@...ts.linux.dev
Subject: drivers/usb/typec/tipd/core.c:1159:17-18: WARNING opportunity for
 min() (fwd)

Just a suggestion.  You could also consider that he code is readable
enough as is.

---------- Forwarded message ----------
Date: Sat, 20 Jan 2024 01:27:01 +0800
From: kernel test robot <lkp@...el.com>
To: oe-kbuild@...ts.linux.dev
Cc: lkp@...el.com, Julia Lawall <julia.lawall@...ia.fr>
Subject: drivers/usb/typec/tipd/core.c:1159:17-18: WARNING opportunity for min()

BCC: lkp@...el.com
CC: oe-kbuild-all@...ts.linux.dev
CC: linux-kernel@...r.kernel.org
TO: Javier Carrasco <javier.carrasco@...fvision.net>
CC: Heikki Krogerus <heikki.krogerus@...ux.intel.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   9d1694dc91ce7b80bc96d6d8eaf1a1eca668d847
commit: 4c3ea81aa8e11400f24e5541bf46c2cadb4202e9 usb: typec: tipd: add patch update support for tps6598x
date:   2 weeks ago
:::::: branch date: 15 hours ago
:::::: commit date: 2 weeks ago
config: i386-randconfig-053-20240118 (https://download.01.org/0day-ci/archive/20240120/202401200150.XOjrMEhu-lkp@intel.com/config)
compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Julia Lawall <julia.lawall@...ia.fr>
| Closes: https://lore.kernel.org/r/202401200150.XOjrMEhu-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> drivers/usb/typec/tipd/core.c:1159:17-18: WARNING opportunity for min()

vim +1159 drivers/usb/typec/tipd/core.c

7e7a3c815d22170 Abdel Alkuor    2023-10-03  1127
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1128  static int tps6598x_apply_patch(struct tps6598x *tps)
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1129  {
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1130  	u8 in = TPS_PTCS_CONTENT_DEV | TPS_PTCS_CONTENT_APP;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1131  	u8 out[TPS_MAX_LEN] = {0};
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1132  	size_t in_len = sizeof(in);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1133  	size_t copied_bytes = 0;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1134  	size_t bytes_left;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1135  	const struct firmware *fw;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1136  	const char *firmware_name;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1137  	int ret;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1138
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1139  	ret = device_property_read_string(tps->dev, "firmware-name",
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1140  					  &firmware_name);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1141  	if (ret)
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1142  		return ret;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1143
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1144  	ret = tps_request_firmware(tps, &fw);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1145  	if (ret)
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1146  		return ret;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1147
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1148  	ret = tps6598x_exec_cmd(tps, "PTCs", in_len, &in,
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1149  				TPS_PTCS_OUT_BYTES, out);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1150  	if (ret || out[TPS_PTCS_STATUS] == TPS_PTCS_STATUS_FAIL) {
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1151  		if (!ret)
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1152  			ret = -EBUSY;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1153  		dev_err(tps->dev, "Update start failed (%d)\n", ret);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1154  		goto release_fw;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1155  	}
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1156
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1157  	bytes_left = fw->size;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1158  	while (bytes_left) {
4c3ea81aa8e1140 Javier Carrasco 2023-12-14 @1159  		if (bytes_left < TPS_MAX_LEN)
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1160  			in_len = bytes_left;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1161  		else
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1162  			in_len = TPS_MAX_LEN;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1163  		ret = tps6598x_exec_cmd(tps, "PTCd", in_len,
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1164  					fw->data + copied_bytes,
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1165  					TPS_PTCD_OUT_BYTES, out);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1166  		if (ret || out[TPS_PTCD_TRANSFER_STATUS] ||
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1167  		    out[TPS_PTCD_LOADING_STATE] == TPS_PTCD_LOAD_ERR) {
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1168  			if (!ret)
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1169  				ret = -EBUSY;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1170  			dev_err(tps->dev, "Patch download failed (%d)\n", ret);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1171  			goto release_fw;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1172  		}
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1173  		copied_bytes += in_len;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1174  		bytes_left -= in_len;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1175  	}
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1176
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1177  	ret = tps6598x_exec_cmd(tps, "PTCc", 0, NULL, TPS_PTCC_OUT_BYTES, out);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1178  	if (ret || out[TPS_PTCC_DEV] || out[TPS_PTCC_APP]) {
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1179  		if (!ret)
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1180  			ret = -EBUSY;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1181  		dev_err(tps->dev, "Update completion failed (%d)\n", ret);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1182  		goto release_fw;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1183  	}
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1184  	msleep(TPS_SETUP_MS);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1185  	dev_info(tps->dev, "Firmware update succeeded\n");
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1186
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1187  release_fw:
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1188  	release_firmware(fw);
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1189
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1190  	return ret;
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1191  };
4c3ea81aa8e1140 Javier Carrasco 2023-12-14  1192

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ