Skip to contentSkip to conversation

drivers/scsi/bfa/bfa_fcs_lport.c:1912 bfa_fcs_lport_fdmi_build_rhba_pyld() warn: signedness bug returning '(-12)'

PATCH New Dan Carpenter 1 participant 1 message Feb 27, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 215/226 drivers/scsi/bfa/bfa_fcs_lport.c:1912 bfa_fcs_lport_fdmi_build_rhba_pyld() warn: signedness bug returning '(-12)'

Hi Lee,

First bad commit (maybe != root cause):

tree:   https://git.linaro.org/people/lee.jones/linux.git tb-fix-w1-warnings
head:   49fe493a5f7cebaec70944df919df3350d4cb520
commit: ffdcc79844033bab9aae2f65246b91334831ee11 [215/226] fixup! scsi: bfa: bfa_fcs_lport: Move a large struct from the stack onto the heap
config: xtensa-randconfig-m031-20210227 (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate

smatch warnings:
drivers/scsi/bfa/bfa_fcs_lport.c:1912 bfa_fcs_lport_fdmi_build_rhba_pyld() warn: signedness bug returning '(-12)'

vim +1912 drivers/scsi/bfa/bfa_fcs_lport.c

a36c61f9025b8924 Krishna Gudipati 2010-09-15 1899 static u16

                                                                      ^^^
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1900  bfa_fcs_lport_fdmi_build_rhba_pyld(struct bfa_fcs_lport_fdmi_s *fdmi, u8 *pyld)
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1901  {
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1902  	struct bfa_fcs_lport_s *port = fdmi->ms->port;
ffdcc79844033bab Lee Jones          2021-02-26  1903  	struct bfa_fcs_fdmi_hba_attr_s *fcs_hba_attr;
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1904  	struct fdmi_rhba_s *rhba = (struct fdmi_rhba_s *) pyld;
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1905  	struct fdmi_attr_s *attr;
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1906  	u8        *curr_ptr;
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1907  	u16        len, count;
50444a340028119c Maggie             2010-11-29  1908  	u16	templen;
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1909  
ffdcc79844033bab Lee Jones          2021-02-26  1910  	fcs_hba_attr = kzalloc(sizeof(*fcs_hba_attr), GFP_KERNEL);
ffdcc79844033bab Lee Jones          2021-02-26  1911  	if (!fcs_hba_attr)
7ba45b2cf0939bf6 Lee Jones          2021-02-25 @1912  		return -ENOMEM;
                                                                ^^^^^^^^^^^^^^^

-ENOMEM gets truncated to u16

7ba45b2cf0939bf6 Lee Jones          2021-02-25  1913  
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1914  	/*
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1915  	 * get hba attributes
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1916  	 */
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1917  	bfa_fcs_fdmi_get_hbaattr(fdmi, fcs_hba_attr);
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1918  
a36c61f9025b8924 Krishna Gudipati   2010-09-15  1919  	rhba->hba_id = bfa_fcs_lport_get_pwwn(port);

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