NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/58634: smsc(4): uninitialized stack data returned on I/O error in smsc_uno_miibus_readreg



>Number:         58634
>Category:       kern
>Synopsis:       smsc(4): uninitialized stack data returned on I/O error in smsc_uno_miibus_readreg
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 24 20:50:01 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, ...
>Organization:
The NetBSMSCD Miidation
>Environment:
>Description:
*** CID 1597788:  Error handling issues  (CHECKED_RETURN)
/sys/dev/usb/if_smsc.c: 302 in smsc_uno_miibus_readreg()
296     	if (smsc_wait_for_bits(un, SMSC_MII_ADDR, SMSC_MII_BUSY) != 0) {
297     		smsc_warn_printf(un, "MII read timeout\n");
298     		*val = 0;
299     		return ETIMEDOUT;
300     	}
301     
>>>     CID 1597788:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "smsc_readreg" without checking return value (as is done elsewhere 9 out of 10 times).
302     	smsc_readreg(un, SMSC_MII_DATA, &data);
303     
304     	*val = data & 0xffff;
305     	return 0;
306     }
307     

smsc_readreg doesn't guarantee data is initialized on error.
>How-To-Repeat:
code inspection
>Fix:
Yes, please!  Check for smsc_readreg error and just return 0 or something in this case.



Home | Main Index | Thread Index | Old Index