]> git.baikalelectronics.ru Git - kernel.git/commit
net: hso: check for allocation failure in hso_create_bulk_serial_device()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 14 May 2021 14:24:48 +0000 (17:24 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 May 2021 20:51:35 +0000 (13:51 -0700)
commitdc47ea9f4853d1fd2c411b0e90bc9d65cc7d0251
treee5775d99dc39b62639cde7b551e80e090aaa5f11
parent919d2db78e318846d1ed24a106676dbf21f93823
net: hso: check for allocation failure in hso_create_bulk_serial_device()

In current kernels, small allocations never actually fail so this
patch shouldn't affect runtime.

Originally this error handling code written with the idea that if
the "serial->tiocmget" allocation failed, then we would continue
operating instead of bailing out early.  But in later years we added
an unchecked dereference on the next line.

serial->tiocmget->serial_state_notification = kzalloc();
        ^^^^^^^^^^^^^^^^^^

Since these allocations are never going fail in real life, this is
mostly a philosophical debate, but I think bailing out early is the
correct behavior that the user would want.  And generally it's safer to
bail as soon an error happens.

Fixes: 790e97cf3b85 ("usb: hso: obey DMA rules in tiocmget")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/hso.c