From patchwork Mon Nov 16 12:35:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linu Cherian X-Patchwork-Id: 11908391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD731C5519F for ; Mon, 16 Nov 2020 12:47:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49E2D22409 for ; Mon, 16 Nov 2020 12:47:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="13E+teUc"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="WILndzDa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49E2D22409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=marvell.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4fi0kAGZ40Ffn39QNHzPj/R1hhWqP9CqFMPmoAsxmOo=; b=13E+teUcdglM2hO35/13+6a6R nBLZG7QDqz5JVZtstZ7JkefVWA/9Jt3kekk9WQAVdDQjYOj+OQyCmMfvwGHZbYTgvJ+0xqbC7wFfP 0X1PVWnIO8Ma9y9ho+N9p5U9MdoL1TdCFhBVE+UXiI6alEbyzCf6k35AfzWzrxbAfMUHhaao0w0Eh pnAEEa5QkBR43qcg0rYYCQSymTnKnj94WZl/uVRaW0IoQ0vh72kuZ3NqpuhDFPcPHi1CuWJsH9g63 UnQB5NQRIkBJqhmwsBQcZ4k+tAiE5ALzO3o+qhx3NekqhUfykm0jR1jSDjCv4UNOOXff8fAdZBqXG Sty8sXF5Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kedjk-0000hl-60; Mon, 16 Nov 2020 12:36:00 +0000 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kedjh-0000h4-F6 for linux-arm-kernel@lists.infradead.org; Mon, 16 Nov 2020 12:35:58 +0000 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AGCU5v1022152; Mon, 16 Nov 2020 04:35:49 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=bMiMF6bHUEJrWeAPNW+vYTur1i8lIXjWzs+JyUKd0jo=; b=WILndzDaEHmtt7ZMcCL1eNEq3zw01ROj5f6S1aHkn5Vx6MoX2s9dWrsWxZ1RamwE7d5w cgpzteeynboUbSsa49g/4O2YFiaFcsXBTGSvCxpxsGl5lx9HgC+MCKE5hYyfycLnJKR4 9lg0+hgmChVBcLIEySd2v1se+gMmE3sU6/JfhjJFlSUoUGJ41MxNgbTfJepm18nTBVBE n7Mlyh24tTB7utKleP0lSJfl0uGGvys4ZxN6IywckkFy0bLlCwI7l+Cx+DzU6MJqTeVQ FI7cyuPnLOt9uuGI8r+Ac1mOfVAvV8xL/+WQECi1XSeijLk+RNDf6CTBQ4njitGE/yrE Bw== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 34tfmscxcs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 16 Nov 2020 04:35:49 -0800 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 16 Nov 2020 04:35:48 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 16 Nov 2020 04:35:47 -0800 Received: from virtx40.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 16 Nov 2020 04:35:44 -0800 From: Linu Cherian To: , Subject: [PATCH stable-v5.9 2/2] coresight: Fix uninitialised pointer bug in etm_setup_aux() Date: Mon, 16 Nov 2020 18:05:10 +0530 Message-ID: <20201116123510.28980-2-lcherian@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201116123510.28980-1-lcherian@marvell.com> References: <20201116123510.28980-1-lcherian@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-16_05:2020-11-13, 2020-11-16 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201116_073557_614057_47EB91C5 X-CRM114-Status: GOOD ( 18.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel test robot , mathieu.poirier@linaro.org, suzuki.poulose@arm.com, coresight@lists.linaro.org, linuc.decode@gmail.com, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Mike Leach commit 39a7661dcf655c8198fd5d72412f5030a8e58444 upstream. Commit [bb1860efc817] changed the sink handling code introducing an uninitialised pointer bug. This results in the default sink selection failing. Prior to commit: static void etm_setup_aux(...) struct coresight_device *sink; /* First get the selected sink from user space. */ if (event->attr.config2) { id = (u32)event->attr.config2; sink = coresight_get_sink_by_id(id); } else { sink = coresight_get_enabled_sink(true); } *sink always initialised - possibly to NULL which triggers the automatic sink selection. After commit: static void etm_setup_aux(...) struct coresight_device *sink; /* First get the selected sink from user space. */ if (event->attr.config2) { id = (u32)event->attr.config2; sink = coresight_get_sink_by_id(id); } *sink pointer uninitialised when not providing a sink on the perf command line. This breaks later checks to enable automatic sink selection. Fixes: bb1860efc817 ("coresight: etm: perf: Sink selection using sysfs is deprecated") Signed-off-by: Mike Leach Signed-off-by: Mathieu Poirier Link: https://lore.kernel.org/r/20201029164559.1268531-3-mathieu.poirier@linaro.org Signed-off-by: Greg Kroah-Hartman Reported-by: kernel test robot --- drivers/hwtracing/coresight/coresight-etm-perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 75379184f391..9a8d03e62a75 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -210,7 +210,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, u32 id; int cpu = event->cpu; cpumask_t *mask; - struct coresight_device *sink; + struct coresight_device *sink = NULL; struct etm_event_data *event_data = NULL; event_data = alloc_event_data(cpu);