All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: drivers/s390/crypto/zcrypt_api.c:986 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'pref_weight'.
Date: Fri, 12 Jun 2020 02:02:33 -0700	[thread overview]
Message-ID: <20200612090233.GG4151@kadam> (raw)

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b29482fde649c72441d5478a4ea2c52c56d97a5e
commit: a7367997abb64b5e5a4f6fe6091629440b10da40 s390/zcrypt: ep11 structs rework, export zcrypt_send_ep11_cprb
config: s390-randconfig-m031-20200611 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0

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

New smatch warnings:
drivers/s390/crypto/zcrypt_api.c:986 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:1008 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'weight'.

Old smatch warnings:
drivers/s390/crypto/zcrypt_api.c:676 zcrypt_rsa_modexpo() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:694 zcrypt_rsa_modexpo() error: uninitialized symbol 'weight'.
drivers/s390/crypto/zcrypt_api.c:760 zcrypt_rsa_crt() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:778 zcrypt_rsa_crt() error: uninitialized symbol 'weight'.
drivers/s390/crypto/zcrypt_api.c:824 _zcrypt_send_cprb() warn: always true condition '(tdom >= 0) => (0-u16max >= 0)'
drivers/s390/crypto/zcrypt_api.c:846 _zcrypt_send_cprb() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:867 _zcrypt_send_cprb() error: uninitialized symbol 'weight'.
drivers/s390/crypto/zcrypt_api.c:1065 zcrypt_rng() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:1079 zcrypt_rng() error: uninitialized symbol 'weight'.

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a7367997abb64b5e5a4f6fe6091629440b10da40
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout a7367997abb64b5e5a4f6fe6091629440b10da40
vim +/pref_weight +986 drivers/s390/crypto/zcrypt_api.c

a7367997abb64b Harald Freudenberger 2019-08-30   926  static long _zcrypt_send_ep11_cprb(struct ap_perms *perms,
00fab2350e6b91 Harald Freudenberger 2018-09-17   927  				   struct ep11_urb *xcrb)
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   928  {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   929  	struct zcrypt_card *zc, *pref_zc;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   930  	struct zcrypt_queue *zq, *pref_zq;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   931  	struct ep11_target_dev *targets;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   932  	unsigned short target_num;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   933  	unsigned int weight, pref_weight;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   934  	unsigned int func_code;
34a15167739412 Ingo Tuchscherer     2016-08-25   935  	struct ap_message ap_msg;
13b251bdc8b97c Harald Freudenberger 2016-11-25   936  	int qid = 0, rc = -ENODEV;
01396a374c3d31 Harald Freudenberger 2019-02-22   937  	struct module *mod;
13b251bdc8b97c Harald Freudenberger 2016-11-25   938  
13b251bdc8b97c Harald Freudenberger 2016-11-25   939  	trace_s390_zcrypt_req(xcrb, TP_ZSENDEP11CPRB);
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   940  
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28   941  	ap_init_message(&ap_msg);
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28   942  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   943  	target_num = (unsigned short) xcrb->targets_num;
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   944  
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   945  	/* empty list indicates autoselect (all available targets) */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   946  	targets = NULL;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   947  	if (target_num != 0) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   948  		struct ep11_target_dev __user *uptr;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   949  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   950  		targets = kcalloc(target_num, sizeof(*targets), GFP_KERNEL);
13b251bdc8b97c Harald Freudenberger 2016-11-25   951  		if (!targets) {
913140e221567b Arnd Bergmann        2019-04-08   952  			func_code = 0;
13b251bdc8b97c Harald Freudenberger 2016-11-25   953  			rc = -ENOMEM;
13b251bdc8b97c Harald Freudenberger 2016-11-25   954  			goto out;
13b251bdc8b97c Harald Freudenberger 2016-11-25   955  		}
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   956  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   957  		uptr = (struct ep11_target_dev __force __user *) xcrb->targets;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   958  		if (copy_from_user(targets, uptr,
13b251bdc8b97c Harald Freudenberger 2016-11-25   959  				   target_num * sizeof(*targets))) {
913140e221567b Arnd Bergmann        2019-04-08   960  			func_code = 0;
13b251bdc8b97c Harald Freudenberger 2016-11-25   961  			rc = -EFAULT;
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28   962  			goto out_free;
13b251bdc8b97c Harald Freudenberger 2016-11-25   963  		}
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   964  	}
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   965  
34a15167739412 Ingo Tuchscherer     2016-08-25   966  	rc = get_ep11cprb_fc(xcrb, &ap_msg, &func_code);
34a15167739412 Ingo Tuchscherer     2016-08-25   967  	if (rc)
e28d2af43614eb Ingo Tuchscherer     2016-08-25   968  		goto out_free;
34a15167739412 Ingo Tuchscherer     2016-08-25   969  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   970  	pref_zc = NULL;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   971  	pref_zq = NULL;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   972  	spin_lock(&zcrypt_list_lock);
e28d2af43614eb Ingo Tuchscherer     2016-08-25   973  	for_each_zcrypt_card(zc) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   974  		/* Check for online EP11 cards */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   975  		if (!zc->online || !(zc->card->functions & 0x04000000))
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   976  			continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   977  		/* Check for user selected EP11 card */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   978  		if (targets &&
e28d2af43614eb Ingo Tuchscherer     2016-08-25   979  		    !is_desired_ep11_card(zc->card->id, target_num, targets))
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   980  			continue;
00fab2350e6b91 Harald Freudenberger 2018-09-17   981  		/* check if device node has admission for this card */
00fab2350e6b91 Harald Freudenberger 2018-09-17   982  		if (!zcrypt_check_card(perms, zc->card->id))
00fab2350e6b91 Harald Freudenberger 2018-09-17   983  			continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   984  		/* get weight index of the card device	*/
e28d2af43614eb Ingo Tuchscherer     2016-08-25   985  		weight = speed_idx_ep11(func_code) * zc->speed_rating[SECKEY];
e47de21dd35bad Ingo Tuchscherer     2016-10-14  @986  		if (zcrypt_card_compare(zc, pref_zc, weight, pref_weight))
                                                                                                             ^^^^^^^^^^^
Not initialized on first iteration through the loop.

34a15167739412 Ingo Tuchscherer     2016-08-25   987  			continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   988  		for_each_zcrypt_queue(zq, zc) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   989  			/* check if device is online and eligible */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   990  			if (!zq->online ||
148784246ef2d8 Harald Freudenberger 2016-10-27   991  			    !zq->ops->send_ep11_cprb ||
e28d2af43614eb Ingo Tuchscherer     2016-08-25   992  			    (targets &&
e28d2af43614eb Ingo Tuchscherer     2016-08-25   993  			     !is_desired_ep11_queue(zq->queue->qid,
e28d2af43614eb Ingo Tuchscherer     2016-08-25   994  						    target_num, targets)))
34a15167739412 Ingo Tuchscherer     2016-08-25   995  				continue;
00fab2350e6b91 Harald Freudenberger 2018-09-17   996  			/* check if device node has admission for this queue */
00fab2350e6b91 Harald Freudenberger 2018-09-17   997  			if (!zcrypt_check_queue(perms,
00fab2350e6b91 Harald Freudenberger 2018-09-17   998  						AP_QID_QUEUE(zq->queue->qid)))
00fab2350e6b91 Harald Freudenberger 2018-09-17   999  				continue;
e47de21dd35bad Ingo Tuchscherer     2016-10-14  1000  			if (zcrypt_queue_compare(zq, pref_zq,
e47de21dd35bad Ingo Tuchscherer     2016-10-14  1001  						 weight, pref_weight))
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1002  				continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1003  			pref_zc = zc;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1004  			pref_zq = zq;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1005  			pref_weight = weight;
34a15167739412 Ingo Tuchscherer     2016-08-25  1006  		}
34a15167739412 Ingo Tuchscherer     2016-08-25  1007  	}
01396a374c3d31 Harald Freudenberger 2019-02-22 @1008  	pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight);
                                                                                                            ^^^^^^
>From a static analysis perspective it's obvious why it generates a
warning for this, but it's probably wrong.

e28d2af43614eb Ingo Tuchscherer     2016-08-25  1009  	spin_unlock(&zcrypt_list_lock);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1010  
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1011  	if (!pref_zq) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1012  		rc = -ENODEV;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1013  		goto out_free;
34a15167739412 Ingo Tuchscherer     2016-08-25  1014  	}
34a15167739412 Ingo Tuchscherer     2016-08-25  1015  
13b251bdc8b97c Harald Freudenberger 2016-11-25  1016  	qid = pref_zq->queue->qid;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1017  	rc = pref_zq->ops->send_ep11_cprb(pref_zq, xcrb, &ap_msg);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1018  
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1019  	spin_lock(&zcrypt_list_lock);
01396a374c3d31 Harald Freudenberger 2019-02-22  1020  	zcrypt_drop_queue(pref_zc, pref_zq, mod, weight);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1021  	spin_unlock(&zcrypt_list_lock);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1022  
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1023  out_free:
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1024  	kfree(targets);
13b251bdc8b97c Harald Freudenberger 2016-11-25  1025  out:
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28  1026  	ap_release_message(&ap_msg);
13b251bdc8b97c Harald Freudenberger 2016-11-25  1027  	trace_s390_zcrypt_rep(xcrb, func_code, rc,
13b251bdc8b97c Harald Freudenberger 2016-11-25  1028  			      AP_QID_CARD(qid), AP_QID_QUEUE(qid));
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20  1029  	return rc;
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20  1030  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 22854 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: drivers/s390/crypto/zcrypt_api.c:986 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'pref_weight'.
Date: Fri, 12 Jun 2020 02:02:33 -0700	[thread overview]
Message-ID: <20200612090233.GG4151@kadam> (raw)

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b29482fde649c72441d5478a4ea2c52c56d97a5e
commit: a7367997abb64b5e5a4f6fe6091629440b10da40 s390/zcrypt: ep11 structs rework, export zcrypt_send_ep11_cprb
config: s390-randconfig-m031-20200611 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0

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

New smatch warnings:
drivers/s390/crypto/zcrypt_api.c:986 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:1008 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'weight'.

Old smatch warnings:
drivers/s390/crypto/zcrypt_api.c:676 zcrypt_rsa_modexpo() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:694 zcrypt_rsa_modexpo() error: uninitialized symbol 'weight'.
drivers/s390/crypto/zcrypt_api.c:760 zcrypt_rsa_crt() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:778 zcrypt_rsa_crt() error: uninitialized symbol 'weight'.
drivers/s390/crypto/zcrypt_api.c:824 _zcrypt_send_cprb() warn: always true condition '(tdom >= 0) => (0-u16max >= 0)'
drivers/s390/crypto/zcrypt_api.c:846 _zcrypt_send_cprb() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:867 _zcrypt_send_cprb() error: uninitialized symbol 'weight'.
drivers/s390/crypto/zcrypt_api.c:1065 zcrypt_rng() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:1079 zcrypt_rng() error: uninitialized symbol 'weight'.

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a7367997abb64b5e5a4f6fe6091629440b10da40
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout a7367997abb64b5e5a4f6fe6091629440b10da40
vim +/pref_weight +986 drivers/s390/crypto/zcrypt_api.c

a7367997abb64b Harald Freudenberger 2019-08-30   926  static long _zcrypt_send_ep11_cprb(struct ap_perms *perms,
00fab2350e6b91 Harald Freudenberger 2018-09-17   927  				   struct ep11_urb *xcrb)
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   928  {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   929  	struct zcrypt_card *zc, *pref_zc;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   930  	struct zcrypt_queue *zq, *pref_zq;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   931  	struct ep11_target_dev *targets;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   932  	unsigned short target_num;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   933  	unsigned int weight, pref_weight;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   934  	unsigned int func_code;
34a15167739412 Ingo Tuchscherer     2016-08-25   935  	struct ap_message ap_msg;
13b251bdc8b97c Harald Freudenberger 2016-11-25   936  	int qid = 0, rc = -ENODEV;
01396a374c3d31 Harald Freudenberger 2019-02-22   937  	struct module *mod;
13b251bdc8b97c Harald Freudenberger 2016-11-25   938  
13b251bdc8b97c Harald Freudenberger 2016-11-25   939  	trace_s390_zcrypt_req(xcrb, TP_ZSENDEP11CPRB);
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   940  
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28   941  	ap_init_message(&ap_msg);
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28   942  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   943  	target_num = (unsigned short) xcrb->targets_num;
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   944  
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   945  	/* empty list indicates autoselect (all available targets) */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   946  	targets = NULL;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   947  	if (target_num != 0) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   948  		struct ep11_target_dev __user *uptr;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   949  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   950  		targets = kcalloc(target_num, sizeof(*targets), GFP_KERNEL);
13b251bdc8b97c Harald Freudenberger 2016-11-25   951  		if (!targets) {
913140e221567b Arnd Bergmann        2019-04-08   952  			func_code = 0;
13b251bdc8b97c Harald Freudenberger 2016-11-25   953  			rc = -ENOMEM;
13b251bdc8b97c Harald Freudenberger 2016-11-25   954  			goto out;
13b251bdc8b97c Harald Freudenberger 2016-11-25   955  		}
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   956  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   957  		uptr = (struct ep11_target_dev __force __user *) xcrb->targets;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   958  		if (copy_from_user(targets, uptr,
13b251bdc8b97c Harald Freudenberger 2016-11-25   959  				   target_num * sizeof(*targets))) {
913140e221567b Arnd Bergmann        2019-04-08   960  			func_code = 0;
13b251bdc8b97c Harald Freudenberger 2016-11-25   961  			rc = -EFAULT;
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28   962  			goto out_free;
13b251bdc8b97c Harald Freudenberger 2016-11-25   963  		}
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   964  	}
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   965  
34a15167739412 Ingo Tuchscherer     2016-08-25   966  	rc = get_ep11cprb_fc(xcrb, &ap_msg, &func_code);
34a15167739412 Ingo Tuchscherer     2016-08-25   967  	if (rc)
e28d2af43614eb Ingo Tuchscherer     2016-08-25   968  		goto out_free;
34a15167739412 Ingo Tuchscherer     2016-08-25   969  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   970  	pref_zc = NULL;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   971  	pref_zq = NULL;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   972  	spin_lock(&zcrypt_list_lock);
e28d2af43614eb Ingo Tuchscherer     2016-08-25   973  	for_each_zcrypt_card(zc) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   974  		/* Check for online EP11 cards */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   975  		if (!zc->online || !(zc->card->functions & 0x04000000))
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   976  			continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   977  		/* Check for user selected EP11 card */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   978  		if (targets &&
e28d2af43614eb Ingo Tuchscherer     2016-08-25   979  		    !is_desired_ep11_card(zc->card->id, target_num, targets))
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   980  			continue;
00fab2350e6b91 Harald Freudenberger 2018-09-17   981  		/* check if device node has admission for this card */
00fab2350e6b91 Harald Freudenberger 2018-09-17   982  		if (!zcrypt_check_card(perms, zc->card->id))
00fab2350e6b91 Harald Freudenberger 2018-09-17   983  			continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   984  		/* get weight index of the card device	*/
e28d2af43614eb Ingo Tuchscherer     2016-08-25   985  		weight = speed_idx_ep11(func_code) * zc->speed_rating[SECKEY];
e47de21dd35bad Ingo Tuchscherer     2016-10-14  @986  		if (zcrypt_card_compare(zc, pref_zc, weight, pref_weight))
                                                                                                             ^^^^^^^^^^^
Not initialized on first iteration through the loop.

34a15167739412 Ingo Tuchscherer     2016-08-25   987  			continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   988  		for_each_zcrypt_queue(zq, zc) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   989  			/* check if device is online and eligible */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   990  			if (!zq->online ||
148784246ef2d8 Harald Freudenberger 2016-10-27   991  			    !zq->ops->send_ep11_cprb ||
e28d2af43614eb Ingo Tuchscherer     2016-08-25   992  			    (targets &&
e28d2af43614eb Ingo Tuchscherer     2016-08-25   993  			     !is_desired_ep11_queue(zq->queue->qid,
e28d2af43614eb Ingo Tuchscherer     2016-08-25   994  						    target_num, targets)))
34a15167739412 Ingo Tuchscherer     2016-08-25   995  				continue;
00fab2350e6b91 Harald Freudenberger 2018-09-17   996  			/* check if device node has admission for this queue */
00fab2350e6b91 Harald Freudenberger 2018-09-17   997  			if (!zcrypt_check_queue(perms,
00fab2350e6b91 Harald Freudenberger 2018-09-17   998  						AP_QID_QUEUE(zq->queue->qid)))
00fab2350e6b91 Harald Freudenberger 2018-09-17   999  				continue;
e47de21dd35bad Ingo Tuchscherer     2016-10-14  1000  			if (zcrypt_queue_compare(zq, pref_zq,
e47de21dd35bad Ingo Tuchscherer     2016-10-14  1001  						 weight, pref_weight))
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1002  				continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1003  			pref_zc = zc;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1004  			pref_zq = zq;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1005  			pref_weight = weight;
34a15167739412 Ingo Tuchscherer     2016-08-25  1006  		}
34a15167739412 Ingo Tuchscherer     2016-08-25  1007  	}
01396a374c3d31 Harald Freudenberger 2019-02-22 @1008  	pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight);
                                                                                                            ^^^^^^
>From a static analysis perspective it's obvious why it generates a
warning for this, but it's probably wrong.

e28d2af43614eb Ingo Tuchscherer     2016-08-25  1009  	spin_unlock(&zcrypt_list_lock);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1010  
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1011  	if (!pref_zq) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1012  		rc = -ENODEV;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1013  		goto out_free;
34a15167739412 Ingo Tuchscherer     2016-08-25  1014  	}
34a15167739412 Ingo Tuchscherer     2016-08-25  1015  
13b251bdc8b97c Harald Freudenberger 2016-11-25  1016  	qid = pref_zq->queue->qid;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1017  	rc = pref_zq->ops->send_ep11_cprb(pref_zq, xcrb, &ap_msg);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1018  
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1019  	spin_lock(&zcrypt_list_lock);
01396a374c3d31 Harald Freudenberger 2019-02-22  1020  	zcrypt_drop_queue(pref_zc, pref_zq, mod, weight);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1021  	spin_unlock(&zcrypt_list_lock);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1022  
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1023  out_free:
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1024  	kfree(targets);
13b251bdc8b97c Harald Freudenberger 2016-11-25  1025  out:
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28  1026  	ap_release_message(&ap_msg);
13b251bdc8b97c Harald Freudenberger 2016-11-25  1027  	trace_s390_zcrypt_rep(xcrb, func_code, rc,
13b251bdc8b97c Harald Freudenberger 2016-11-25  1028  			      AP_QID_CARD(qid), AP_QID_QUEUE(qid));
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20  1029  	return rc;
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20  1030  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 22854 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Harald Freudenberger <freude@linux.ibm.com>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org, Vasily Gorbik <gor@linux.ibm.com>
Subject: drivers/s390/crypto/zcrypt_api.c:986 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'pref_weight'.
Date: Fri, 12 Jun 2020 02:02:33 -0700 (PDT)	[thread overview]
Message-ID: <20200612090233.GG4151@kadam> (raw)

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b29482fde649c72441d5478a4ea2c52c56d97a5e
commit: a7367997abb64b5e5a4f6fe6091629440b10da40 s390/zcrypt: ep11 structs rework, export zcrypt_send_ep11_cprb
config: s390-randconfig-m031-20200611 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0

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

New smatch warnings:
drivers/s390/crypto/zcrypt_api.c:986 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:1008 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'weight'.

Old smatch warnings:
drivers/s390/crypto/zcrypt_api.c:676 zcrypt_rsa_modexpo() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:694 zcrypt_rsa_modexpo() error: uninitialized symbol 'weight'.
drivers/s390/crypto/zcrypt_api.c:760 zcrypt_rsa_crt() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:778 zcrypt_rsa_crt() error: uninitialized symbol 'weight'.
drivers/s390/crypto/zcrypt_api.c:824 _zcrypt_send_cprb() warn: always true condition '(tdom >= 0) => (0-u16max >= 0)'
drivers/s390/crypto/zcrypt_api.c:846 _zcrypt_send_cprb() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:867 _zcrypt_send_cprb() error: uninitialized symbol 'weight'.
drivers/s390/crypto/zcrypt_api.c:1065 zcrypt_rng() error: uninitialized symbol 'pref_weight'.
drivers/s390/crypto/zcrypt_api.c:1079 zcrypt_rng() error: uninitialized symbol 'weight'.

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a7367997abb64b5e5a4f6fe6091629440b10da40
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout a7367997abb64b5e5a4f6fe6091629440b10da40
vim +/pref_weight +986 drivers/s390/crypto/zcrypt_api.c

a7367997abb64b Harald Freudenberger 2019-08-30   926  static long _zcrypt_send_ep11_cprb(struct ap_perms *perms,
00fab2350e6b91 Harald Freudenberger 2018-09-17   927  				   struct ep11_urb *xcrb)
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   928  {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   929  	struct zcrypt_card *zc, *pref_zc;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   930  	struct zcrypt_queue *zq, *pref_zq;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   931  	struct ep11_target_dev *targets;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   932  	unsigned short target_num;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   933  	unsigned int weight, pref_weight;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   934  	unsigned int func_code;
34a15167739412 Ingo Tuchscherer     2016-08-25   935  	struct ap_message ap_msg;
13b251bdc8b97c Harald Freudenberger 2016-11-25   936  	int qid = 0, rc = -ENODEV;
01396a374c3d31 Harald Freudenberger 2019-02-22   937  	struct module *mod;
13b251bdc8b97c Harald Freudenberger 2016-11-25   938  
13b251bdc8b97c Harald Freudenberger 2016-11-25   939  	trace_s390_zcrypt_req(xcrb, TP_ZSENDEP11CPRB);
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   940  
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28   941  	ap_init_message(&ap_msg);
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28   942  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   943  	target_num = (unsigned short) xcrb->targets_num;
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   944  
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   945  	/* empty list indicates autoselect (all available targets) */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   946  	targets = NULL;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   947  	if (target_num != 0) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   948  		struct ep11_target_dev __user *uptr;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   949  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   950  		targets = kcalloc(target_num, sizeof(*targets), GFP_KERNEL);
13b251bdc8b97c Harald Freudenberger 2016-11-25   951  		if (!targets) {
913140e221567b Arnd Bergmann        2019-04-08   952  			func_code = 0;
13b251bdc8b97c Harald Freudenberger 2016-11-25   953  			rc = -ENOMEM;
13b251bdc8b97c Harald Freudenberger 2016-11-25   954  			goto out;
13b251bdc8b97c Harald Freudenberger 2016-11-25   955  		}
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   956  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   957  		uptr = (struct ep11_target_dev __force __user *) xcrb->targets;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   958  		if (copy_from_user(targets, uptr,
13b251bdc8b97c Harald Freudenberger 2016-11-25   959  				   target_num * sizeof(*targets))) {
913140e221567b Arnd Bergmann        2019-04-08   960  			func_code = 0;
13b251bdc8b97c Harald Freudenberger 2016-11-25   961  			rc = -EFAULT;
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28   962  			goto out_free;
13b251bdc8b97c Harald Freudenberger 2016-11-25   963  		}
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   964  	}
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   965  
34a15167739412 Ingo Tuchscherer     2016-08-25   966  	rc = get_ep11cprb_fc(xcrb, &ap_msg, &func_code);
34a15167739412 Ingo Tuchscherer     2016-08-25   967  	if (rc)
e28d2af43614eb Ingo Tuchscherer     2016-08-25   968  		goto out_free;
34a15167739412 Ingo Tuchscherer     2016-08-25   969  
e28d2af43614eb Ingo Tuchscherer     2016-08-25   970  	pref_zc = NULL;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   971  	pref_zq = NULL;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   972  	spin_lock(&zcrypt_list_lock);
e28d2af43614eb Ingo Tuchscherer     2016-08-25   973  	for_each_zcrypt_card(zc) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   974  		/* Check for online EP11 cards */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   975  		if (!zc->online || !(zc->card->functions & 0x04000000))
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   976  			continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   977  		/* Check for user selected EP11 card */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   978  		if (targets &&
e28d2af43614eb Ingo Tuchscherer     2016-08-25   979  		    !is_desired_ep11_card(zc->card->id, target_num, targets))
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20   980  			continue;
00fab2350e6b91 Harald Freudenberger 2018-09-17   981  		/* check if device node has admission for this card */
00fab2350e6b91 Harald Freudenberger 2018-09-17   982  		if (!zcrypt_check_card(perms, zc->card->id))
00fab2350e6b91 Harald Freudenberger 2018-09-17   983  			continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   984  		/* get weight index of the card device	*/
e28d2af43614eb Ingo Tuchscherer     2016-08-25   985  		weight = speed_idx_ep11(func_code) * zc->speed_rating[SECKEY];
e47de21dd35bad Ingo Tuchscherer     2016-10-14  @986  		if (zcrypt_card_compare(zc, pref_zc, weight, pref_weight))
                                                                                                             ^^^^^^^^^^^
Not initialized on first iteration through the loop.

34a15167739412 Ingo Tuchscherer     2016-08-25   987  			continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25   988  		for_each_zcrypt_queue(zq, zc) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25   989  			/* check if device is online and eligible */
e28d2af43614eb Ingo Tuchscherer     2016-08-25   990  			if (!zq->online ||
148784246ef2d8 Harald Freudenberger 2016-10-27   991  			    !zq->ops->send_ep11_cprb ||
e28d2af43614eb Ingo Tuchscherer     2016-08-25   992  			    (targets &&
e28d2af43614eb Ingo Tuchscherer     2016-08-25   993  			     !is_desired_ep11_queue(zq->queue->qid,
e28d2af43614eb Ingo Tuchscherer     2016-08-25   994  						    target_num, targets)))
34a15167739412 Ingo Tuchscherer     2016-08-25   995  				continue;
00fab2350e6b91 Harald Freudenberger 2018-09-17   996  			/* check if device node has admission for this queue */
00fab2350e6b91 Harald Freudenberger 2018-09-17   997  			if (!zcrypt_check_queue(perms,
00fab2350e6b91 Harald Freudenberger 2018-09-17   998  						AP_QID_QUEUE(zq->queue->qid)))
00fab2350e6b91 Harald Freudenberger 2018-09-17   999  				continue;
e47de21dd35bad Ingo Tuchscherer     2016-10-14  1000  			if (zcrypt_queue_compare(zq, pref_zq,
e47de21dd35bad Ingo Tuchscherer     2016-10-14  1001  						 weight, pref_weight))
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1002  				continue;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1003  			pref_zc = zc;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1004  			pref_zq = zq;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1005  			pref_weight = weight;
34a15167739412 Ingo Tuchscherer     2016-08-25  1006  		}
34a15167739412 Ingo Tuchscherer     2016-08-25  1007  	}
01396a374c3d31 Harald Freudenberger 2019-02-22 @1008  	pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight);
                                                                                                            ^^^^^^
From a static analysis perspective it's obvious why it generates a
warning for this, but it's probably wrong.

e28d2af43614eb Ingo Tuchscherer     2016-08-25  1009  	spin_unlock(&zcrypt_list_lock);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1010  
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1011  	if (!pref_zq) {
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1012  		rc = -ENODEV;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1013  		goto out_free;
34a15167739412 Ingo Tuchscherer     2016-08-25  1014  	}
34a15167739412 Ingo Tuchscherer     2016-08-25  1015  
13b251bdc8b97c Harald Freudenberger 2016-11-25  1016  	qid = pref_zq->queue->qid;
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1017  	rc = pref_zq->ops->send_ep11_cprb(pref_zq, xcrb, &ap_msg);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1018  
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1019  	spin_lock(&zcrypt_list_lock);
01396a374c3d31 Harald Freudenberger 2019-02-22  1020  	zcrypt_drop_queue(pref_zc, pref_zq, mod, weight);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1021  	spin_unlock(&zcrypt_list_lock);
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1022  
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1023  out_free:
e28d2af43614eb Ingo Tuchscherer     2016-08-25  1024  	kfree(targets);
13b251bdc8b97c Harald Freudenberger 2016-11-25  1025  out:
89a0c0ec0d2e3c Harald Freudenberger 2018-05-28  1026  	ap_release_message(&ap_msg);
13b251bdc8b97c Harald Freudenberger 2016-11-25  1027  	trace_s390_zcrypt_rep(xcrb, func_code, rc,
13b251bdc8b97c Harald Freudenberger 2016-11-25  1028  			      AP_QID_CARD(qid), AP_QID_QUEUE(qid));
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20  1029  	return rc;
91f3e3eaba4413 Ingo Tuchscherer     2013-11-20  1030  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 22854 bytes --]

             reply	other threads:[~2020-06-12  9:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12  9:02 Dan Carpenter [this message]
2020-06-12  9:02 ` drivers/s390/crypto/zcrypt_api.c:986 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'pref_weight' Dan Carpenter
2020-06-12  9:02 ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2020-06-11 16:01 kernel test robot

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 \
    --in-reply-to=20200612090233.GG4151@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild@lists.01.org \
    /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 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.