From 5c2764c6032b499853b3ab56240d5907a0e108a4 Mon Sep 17 00:00:00 2001 From: Sanjana B Date: Mon, 24 May 2021 12:08:12 +0530 Subject: [PATCH] ASoC: wcd: Add check to stop invalid memory access Catch any unexpected behavior with else case to prevent invalid memory access. Change-Id: I0edad1c645031286ba0528a52fd11655f445df35 Signed-off-by: Sanjana B --- asoc/codecs/wcd9xxx-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/wcd9xxx-core.c b/asoc/codecs/wcd9xxx-core.c index 37099e5de77e..7462cc4532dc 100644 --- a/asoc/codecs/wcd9xxx-core.c +++ b/asoc/codecs/wcd9xxx-core.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2011-2020, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2021, The Linux Foundation. All rights reserved. */ #include @@ -1200,9 +1200,12 @@ static int wcd9xxx_i2c_probe(struct i2c_client *client, wcd9xxx_set_intf_type(WCD9XXX_INTERFACE_TYPE_I2C); return ret; + } else { + ret = -EINVAL; + pr_err("%s: I2C probe in wrong state, ret %d\n", __func__, ret); + goto fail; } - pr_err("%s: I2C probe in wrong state\n", __func__); err_device_init: