Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a0f9980 authored by Karthikeyan Mani's avatar Karthikeyan Mani
Browse files

soc: soundwire: check for valid pointer before dereference



Check if the swr pointer obtained is not NULL before
dereferencing it.

Change-Id: I119141e5fd0b365789f8295d7b43867ede29dd8c
Signed-off-by: default avatarKarthikeyan Mani <kmani@codeaurora.org>
parent c63ec8cd
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
 */

#include <linux/kernel.h>
@@ -998,10 +998,14 @@ static int swr_device_match(struct device *dev, struct device_driver *driver)
	if (!drv)
		return -EINVAL;

	if (dev->type == &swr_dev_type)
	if (dev->type == &swr_dev_type) {
		swr_dev = to_swr_device(dev);
	else
		if (!swr_dev)
			return -EINVAL;
	} else {
		return 0;
	}

	if (drv->id_table)
		return swr_match(drv->id_table, swr_dev) != NULL;