linux-stable/sound/pci/asihpi
Kuninori Morimoto 5c984fe5a1 ALSA: asihpi: check pao in control_message()
[ Upstream commit 9026c0bf23 ]

control_message() might be called with pao = NULL.
Here indicates control_message() as sample.

(B)	static void control_message(struct hpi_adapter_obj *pao, ...)
	{                                                   ^^^
		struct hpi_hw_obj *phw = pao->priv;
		...                      ^^^
	}

(A)	void _HPI_6205(struct hpi_adapter_obj *pao, ...)
	{                                      ^^^
		...
		case HPI_OBJ_CONTROL:
(B)			control_message(pao, phm, phr);
			break;          ^^^
		...
	}

	void HPI_6205(...)
	{
		...
(A)		_HPI_6205(NULL, phm, phr);
		...       ^^^^
	}

Therefore, We will get too many warning via cppcheck, like below

	sound/pci/asihpi/hpi6205.c:238:27: warning: Possible null pointer dereference: pao [nullPointer]
		 struct hpi_hw_obj *phw = pao->priv;
		                          ^
	sound/pci/asihpi/hpi6205.c:433:13: note: Calling function '_HPI_6205', 1st argument 'NULL' value is 0
		  _HPI_6205(NULL, phm, phr);
		            ^
	sound/pci/asihpi/hpi6205.c:401:20: note: Calling function 'control_message', 1st argument 'pao' value is 0
	   control_message(pao, phm, phr);
	                   ^
Set phr->error like many functions doing, and don't call _HPI_6205()
with NULL.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ttypeaqz.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-05 11:14:19 +02:00
..
Makefile
asihpi.c ALSA: asihpi: Kill BUG_ON() usages 2017-09-07 10:52:37 +02:00
hpi.h ALSA: asihpi: New I/O types - AVB & BLUlink, DAB Rf receiver 2014-11-22 22:25:51 +01:00
hpi6000.c ALSA: asihpi: fix an information leak in asihpi_hpi_ioctl() 2014-12-31 14:12:43 +01:00
hpi6000.h
hpi6205.c ALSA: asihpi: check pao in control_message() 2023-04-05 11:14:19 +02:00
hpi6205.h
hpi_internal.h ALSA: asihpi: increase tuner pad cache size 2014-12-18 08:48:24 +01:00
hpi_version.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hpicmn.c ALSA: asihpi: Refactor control cache code. 2014-11-22 22:29:58 +01:00
hpicmn.h ALSA: asihpi: Add support for stream interrupt. 2014-11-22 22:33:13 +01:00
hpidebug.c ALSA: asihpi: Put missing KERN_CONT prefix 2017-08-31 11:01:31 +02:00
hpidebug.h
hpidspcd.c ALSA: asihpi: relax firmware version check 2014-12-18 08:40:06 +01:00
hpidspcd.h
hpifunc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hpimsginit.c ALSA: asihpi: Hardening for potential Spectre v1 2018-05-01 12:58:15 -07:00
hpimsginit.h
hpimsgx.c ALSA: asihpi: Turn off msg/resp logging after DSP has crashed. 2014-11-22 22:33:25 +01:00
hpimsgx.h
hpioctl.c ALSA: asihpi: fix missing pci_disable_device() 2023-01-18 09:26:15 +01:00
hpioctl.h
hpios.c
hpios.h ALSA: asihpi: Add support for stream interrupt. 2014-11-22 22:33:13 +01:00
hpipcida.h