Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2502390pxb; Tue, 12 Oct 2021 07:57:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoq54FuY14hBagSDdyrPw9cVyhclbBkTNqOogCEU6t5gkcqf+hvyTGUA3vJA7QhVtOj3Gz X-Received: by 2002:a17:90b:3e8e:: with SMTP id rj14mr6658264pjb.170.1634050662916; Tue, 12 Oct 2021 07:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634050662; cv=none; d=google.com; s=arc-20160816; b=IKsHA87pgXVKgb2Z+C2DerH+RaJSCVqeu012d1XzjLKLK9bugTXaTYGlarEk4+nLqB uxIbVVhA03/P4n7hWDJdZdUqsGKl/3XPdHcw9o9oZbzCjJVI4vBK4H1kFqkSGLRjGiVQ jL3ofbcPf/j4GvFnqmrOWD4NG423AtyMO0ucvng43bcGJxdMtRKH+U1a7Q6xSROxVJ7z AK4cre3VkrKbuolNw9ZLR8m4tjJk9iNGwPkiulloavwm7Q38mXwQECI2Bm2T6iwF4BAM XY8GJUsnYNUSf9k7xGMoh/likPI8YCed2FTpsZuYyiW7U648gN8H6Gvb7QwbkA3VL+ux sJNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=kvQuZgOwu9ueFfXD7AJDmpYGBMOk4IOVqhV9rOYO1nY=; b=UGtaIn2xJ4VNG5b/zVg1wjNvO8hqilWDtlxqbi9Z0/iZYRV0TqmztgLAF45IqrEyw9 /RxaPC2v9wTDz7B4rYkmBd6Cz4Vfo6nDI1p/bLOj6EkEJI9BgLufpKMbMPxUNyeXD1Ef k47q6MLer5d+gLAjfmeJJUK+vGqGyQBO2p98B5gb+ej/BweiorCDytU2Xf9ec7w0Pb1c KiUlaq8Sg2M25fiUXUDCtjEOt/+SCCWzb1QZUI6M+vV7riobD2dtMQcO43kdeZ/0Beb7 4N3fNcMPtCkNzDJn2fQq+w77zBcfqL9bqAX+H9N7wmIdgYncpnazpeUFoWi/ePyuIT+D N/xQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si10901077pgc.115.2021.10.12.07.57.28; Tue, 12 Oct 2021 07:57:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237316AbhJLO44 (ORCPT + 99 others); Tue, 12 Oct 2021 10:56:56 -0400 Received: from mga03.intel.com ([134.134.136.65]:21810 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237167AbhJLO4z (ORCPT ); Tue, 12 Oct 2021 10:56:55 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10135"; a="227125957" X-IronPort-AV: E=Sophos;i="5.85,367,1624345200"; d="scan'208";a="227125957" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2021 07:54:53 -0700 X-IronPort-AV: E=Sophos;i="5.85,367,1624345200"; d="scan'208";a="486417496" Received: from csharp1-mobl.amr.corp.intel.com (HELO [10.213.183.127]) ([10.213.183.127]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2021 07:54:52 -0700 Subject: Re: [PATCH] soundwire: bus: stop dereferencing invalid slave pointer To: Srinivas Kandagatla , vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, sanyog.r.kale@intel.com, guennadi.liakhovetski@linux.intel.com, rander.wang@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org References: <20211012101521.32087-1-srinivas.kandagatla@linaro.org> From: Pierre-Louis Bossart Message-ID: Date: Tue, 12 Oct 2021 08:32:35 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211012101521.32087-1-srinivas.kandagatla@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/12/21 5:15 AM, Srinivas Kandagatla wrote: > Slave pointer is invalid after end of list iteration, using this > would result in below Memory abort. > > Unable to handle kernel NULL pointer dereference at virtual address 0000000000000004 > ... > Call trace: > __dev_printk+0x34/0x7c > _dev_warn+0x6c/0x90 > sdw_bus_exit_clk_stop+0x194/0x1d0 > swrm_runtime_resume+0x13c/0x238 > pm_generic_runtime_resume+0x2c/0x48 > __rpm_callback+0x44/0x150 > rpm_callback+0x6c/0x78 > rpm_resume+0x314/0x558 > rpm_resume+0x378/0x558 > rpm_resume+0x378/0x558 > __pm_runtime_resume+0x3c/0x88 > > Use bus->dev instead to print this error message. > > Fixes: b50bb8ba369cd ("soundwire: bus: handle -ENODATA errors in clock stop/start sequences") > Signed-off-by: Srinivas Kandagatla Nice catch, even if the 'slave' pointer was valid it makes no sense to use this device for a bus-level operation. Using the bus->dev is the right thing to do. Reviewed-by: Pierre-Louis Bossart > --- > drivers/soundwire/bus.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c > index 1b115734a8f6..67369e941d0d 100644 > --- a/drivers/soundwire/bus.c > +++ b/drivers/soundwire/bus.c > @@ -1110,7 +1110,7 @@ int sdw_bus_exit_clk_stop(struct sdw_bus *bus) > if (!simple_clk_stop) { > ret = sdw_bus_wait_for_clk_prep_deprep(bus, SDW_BROADCAST_DEV_NUM); > if (ret < 0) > - dev_warn(&slave->dev, "clock stop deprepare wait failed:%d\n", ret); > + dev_warn(bus->dev, "clock stop deprepare wait failed:%d\n", ret); > } > > list_for_each_entry(slave, &bus->slaves, node) { >