Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3735289pxk; Tue, 8 Sep 2020 00:34:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZJ1stCXhOKQh+/EnxvKFWlqWMmkJeu26yGxrM4rrCKqGgTPHEZUTikjffx6/aApxrtT3U X-Received: by 2002:a50:ab13:: with SMTP id s19mr24749983edc.357.1599550472001; Tue, 08 Sep 2020 00:34:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599550471; cv=none; d=google.com; s=arc-20160816; b=o9Y6RHUR83hFz/V81OewjUfGNGEDNfJGTrQjrSBgSOQASnBHirTtxzw8IuUGZYtRH/ R/ce1RSPdjbCxeDMLvg5tRq1X0Kf7yYd5CvIc0meaObk4DI7IjGLUXUww3hDVhM/3pSw KI7C/vIHRal06GizIajlkgtw4CHO12ZNAWj4VRBsqFTmSwisfHNg2QZuC3akRWGX9lj1 xcxhQBGXMoZqRAFwMl7FRq88TxHSoHGWGF/o8QGiXjg/7SCp5HOOKGFzIhAw7wkpxMxy lvCDKSk7CFOCnkSfuHQ8WMCtmtzw4Of9F2qXmUh241rqZfbTqhdzv3ddjBuj8ddbd4ex Nekg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=Z6xePb86+fyTMyU63sks1/KLEBxeC0JKq7CsKpwbVgg=; b=rde2AZIIogrC/17hJvdlbESf19ZgQsczqxBOVeCXaVofyLs+LKTjxbB/fSQ4Y/4iCE Th0nV3wYwqYLNd7Rqbk80dqA58vquxFj8h3hvkKf2P0TJ1T8SgwBNjUQYUW5nXJCxyh4 3FZ+bAHo+WScQ5KwGB47h1BM7Xx+c6HI+yl6BvOk+nVYcPgbcow/N9fstqj3vYzdJblA B/DOb3mntmSu/Rb2fM8K9OCr3oM2BrUMgMo889K9GkYgfGFxD2t1FxYFS7GCIYdYBj7a TKNbBtLtOYmeCzSGlLuTCgbuGLTA2ylcf487kuZS0EmxRPzyZN7paOZRAV8h6ylViFJh kr0A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si11263338eds.46.2020.09.08.00.34.09; Tue, 08 Sep 2020 00:34:31 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729455AbgIHHcs (ORCPT + 99 others); Tue, 8 Sep 2020 03:32:48 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:53920 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729373AbgIHHco (ORCPT ); Tue, 8 Sep 2020 03:32:44 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3DF52FB945566D075C61; Tue, 8 Sep 2020 15:32:43 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Tue, 8 Sep 2020 15:32:34 +0800 From: Qi Liu To: , , CC: , , Subject: [PATCH] coresight: Don't allocate pdata->conns when there is no output port Date: Tue, 8 Sep 2020 15:31:28 +0800 Message-ID: <1599550288-41724-1-git-send-email-liuqi115@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When there is no output port, coresight_alloc_conns() still do the following copy connection information to pdata->conns, and this may cause kernel panic. Let's fix it. Signed-off-by: Qi Liu --- drivers/hwtracing/coresight/coresight-platform.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index bfd4423..cdc8824 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -26,12 +26,13 @@ static int coresight_alloc_conns(struct device *dev, struct coresight_platform_data *pdata) { - if (pdata->nr_outport) { - pdata->conns = devm_kcalloc(dev, pdata->nr_outport, - sizeof(*pdata->conns), GFP_KERNEL); - if (!pdata->conns) - return -ENOMEM; - } + if (!pdata->nr_outport) + return -ENOMEM; + + pdata->conns = devm_kcalloc(dev, pdata->nr_outport, + sizeof(*pdata->conns), GFP_KERNEL); + if (!pdata->conns) + return -ENOMEM; return 0; } -- 2.8.1