Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2850498pxa; Mon, 17 Aug 2020 22:42:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNUWG+g+dEz4/l+7yH67i03SpGEn+Sw1qkCL53yt3QE9QYRngHsM7PjteigP0pKya+QEJG X-Received: by 2002:a17:906:cd02:: with SMTP id oz2mr19068671ejb.326.1597729344241; Mon, 17 Aug 2020 22:42:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597729344; cv=none; d=google.com; s=arc-20160816; b=Fer1gcbf1QHZdfsSNnZ2Rw6bj1D6tz6t9KjFLYlDTAwaIM20w9rvIxekf0kPtKPA2m PYYElSHyCd75m+zsWAyYfwun85WNoSa41SiPCFknac8qoM6SeHES8lLOmfkxdhPw6Iu4 yUmx3yGCumB4cODusNsOy0zQqNxgnJNExsAa5pDpmsS6Li1LePcq9rqFlsXN5BOaxd1X h/9qZGJanSL5SU5EfZzyMi4WKZ/uKuHMIqgmQmu889c4YbFm09lZ3zgj1AMiSOEyZvto sG827wgjAjXqic4h+8ZGdovljY6wjrfAQMk57G+6mzGvGhukMNnZLyEOb9+g7/WGEVg3 GAYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=WIwDouI8xjVVMUuopu0D5er1Oar2jKS2oKmPhMYCM+c=; b=RQZBOH4gRZp1gKDhIVnVHVoGY7uHH3EmEf218NViGRnIHwNATX8xmnD9chBDdRLCnh 0JXN7XEJLzNlj/Idx/S/wz1XZsUbSydClCDJW+qLaLEoYh0+8sC5TqgBkDqr5cTOwOBQ nEUwHFDxR2UV+B5Nm6jJIvsj+9AIhRxwJrYWTAENsKpVq9UY3qrcl/+PLHmF+osXHMt5 ZkHJ6RbolADnA1Zbwgne5VetSHxYJk5M/OOku5Mkkm5M4Yc+WRPMU2vqHIDGAD6z+EA0 Agujk1Iph6ZNMH+RjqJbeukEZjlZylE54kfsK8o1BU6fISxtU33K4xMLgqaUwn5unQWq YIBg== 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 n17si7870863edt.242.2020.08.17.22.42.00; Mon, 17 Aug 2020 22:42:24 -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 S1726656AbgHRFlV (ORCPT + 99 others); Tue, 18 Aug 2020 01:41:21 -0400 Received: from mga11.intel.com ([192.55.52.93]:36469 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726382AbgHRFlV (ORCPT ); Tue, 18 Aug 2020 01:41:21 -0400 IronPort-SDR: 857Kh1lZeKN0pBFnaCkPXb4EtOzazQu5PULaq4W8kHbtEgB7BC5S4EqP83FU5Yeq7RunA8/dHs VZjJEMuJJs5Q== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="152477966" X-IronPort-AV: E=Sophos;i="5.76,326,1592895600"; d="scan'208";a="152477966" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 22:41:20 -0700 IronPort-SDR: g6/EUuBcDqKVtR4X9792NgCjrn485h26Oz/qQyg2gI//ZFCoZ7dSKphCRScbg7PYwchpU/aTOo +XWdZxsPjpBw== X-IronPort-AV: E=Sophos;i="5.76,326,1592895600"; d="scan'208";a="471678365" Received: from bard-ubuntu.sh.intel.com ([10.239.13.33]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 22:41:16 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, rander.wang@linux.intel.com, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, mengdong.lin@intel.com, bard.liao@intel.com Subject: [PATCH 0/2] soundwire: fix port_ready[] dynamic allocation in Date: Tue, 18 Aug 2020 01:47:25 +0800 Message-Id: <20200817174727.15139-1-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The existing code allocates memory for the total number of ports. This only works if the ports are contiguous, but will break if e.g. a Devices uses port0, 1, and 14. The port_ready[] array would contain 3 elements, which would lead to an out-of-bounds access. Conversely in other cases, the wrong port index would be used leading to timeouts on prepare. This can be fixed by allocating for the worst-case of 15 ports (DP0..DP14). In addition since the number is now fixed, we can use an array instead of a dynamic allocation. Pierre-Louis Bossart (2): soundwire: add definition for maximum number of ports soundwire: fix port_ready[] dynamic allocation in mipi_disco and ASoC codecs drivers/soundwire/mipi_disco.c | 18 +----------------- drivers/soundwire/slave.c | 4 ++++ include/linux/soundwire/sdw.h | 5 +++-- sound/soc/codecs/max98373-sdw.c | 15 +-------------- sound/soc/codecs/rt1308-sdw.c | 14 +------------- sound/soc/codecs/rt5682-sdw.c | 15 +-------------- sound/soc/codecs/rt700-sdw.c | 15 +-------------- sound/soc/codecs/rt711-sdw.c | 15 +-------------- sound/soc/codecs/rt715-sdw.c | 33 +-------------------------------- 9 files changed, 14 insertions(+), 120 deletions(-) -- 2.17.1