Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp94797pxj; Wed, 12 May 2021 23:41:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYMxfRjNnbn5rBA3Eyk7dED/WcMcty0jOAXOtq26+9LYZ3cuuyAmrEhKTEabcJkO4T2Wfa X-Received: by 2002:a17:907:2662:: with SMTP id ci2mr42271496ejc.459.1620888114076; Wed, 12 May 2021 23:41:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1620888114; cv=pass; d=google.com; s=arc-20160816; b=Ip4wyTwLt2bUs1Y4sXsr9nOPxpTMOWlU6kzPXUC7dRYGwXxAoFQBL0VtwplND3LtcQ 42Y3iWvuESA58qMCuvTxu4eoeQLj6ff50bxaHhJrpMPBIr6omp3P686SfJK/VSjbXAqK rH6TCIERxjZeWmB2d8Y0WSxSGs1hrYhXmU0sQrciu4KQB/tygTOeDrFUWoCLyPPqtN4W cs3Ey8NPOe78RJqmQ2Mywy3clf/7Dy0okbWuU3UJI7AJCzNHLfPZmfvDGgc/cjzLxp4t tXWOeR6SYfl4ffQ+4BY25WXelGoesfuTKfbkRhwINMjlarjiKpxyZWU5Y8y4WYYgbGhc uYUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:subject:cc:to:from:date:dkim-signature; bh=pXfJlPn00Ee4R1bjyWY+94pyHb6aKlnAHCG4D9Y7WRw=; b=TghgRajrYPYxlttMJ+r76hYiehH3WcNMMI6h47e4EcpRGCU9bFaq7+RLPKgxveD+zE cxGheiJwYhvdWGN5TsG1IvsUplOuVId81BcdGVyLC+JEsM4puFxUq7SnL2YyfKUG5Wuo nEr5dAvf69nMaRhw2PX9dTTZ7vpMYhqb+EAEI5mvN/vYM9pcikGSI0qUHNcydZgyxYoN gHPaF/MJzEqzHxeUlpTnJB8RriAYjt80yWeMB9dJ5f5iPr7+ntCXK/CWwyL464SWbxXZ Jej3vmF3YxzzxyQlSQl7PYCpjqJh1ImWW1X4rgNAd66rK9o6i+siRkZprmrgpA2vrcI+ nq3A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=LpU9AYbf; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.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=synaptics.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fy7si2034444ejb.587.2021.05.12.23.41.27; Wed, 12 May 2021 23:41:54 -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; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=LpU9AYbf; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.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=synaptics.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231357AbhEMGlQ (ORCPT + 99 others); Thu, 13 May 2021 02:41:16 -0400 Received: from mail-co1nam11on2042.outbound.protection.outlook.com ([40.107.220.42]:46497 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230063AbhEMGlP (ORCPT ); Thu, 13 May 2021 02:41:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I7ITl16xTsB8n79N9ObK8nwXpPs0Zxnnlruwew/1ES/N0h0Sh+IODNGV43E7CDWyokTN6mDprx7s4L+YVY4MS4Zt35/MUNPEmN9SVkD8yGrmknmSYfLgxDQfVdSz/MJjy84udVNnH/T1mmApsCGo7aYl77mHgURDrfJ3Qx+huJgIsNivqdRi7WMoKfZBSelvW0mUPJTWSE+2wjTLTp4TkYucUk1hTpGkhq9bs06L6+LiyiOuxgZzZMuie0AbggBaFT8oW3qMffx9Dx6/QgeNA2ErZQetSarB4Lojys2+6t4kGN3tYRqbFpQECHriwJwOjonNQ8w+50YNViTmQPrqEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pXfJlPn00Ee4R1bjyWY+94pyHb6aKlnAHCG4D9Y7WRw=; b=T8vjkkSlVAnkhdznw9O31wjW0xMmN8L5Byt334pon6HSh10/uW3m4IBAZKpb4jvm2hv7ywDXhXEcw/GHAA/JlrrFbZS7aun1XVkndvrtrN/gXXeX3dbFgbsm+WEakoAbq3Fyon04Fn4vUiltAo80pbasqMqVoBvYSe3DKGNKgk4EVuVKI8AC5KOlT4q/tb6hdJAyjE8GCc3nOeKqmeQARU0fjg0f0gXzmlw1xqvyvlY62wLBM/ZveG6MN6uPGGMxV9VFTCheDyLsbSZwUPQA2+Kb+fQblmZFzIcY+cMWMqyL3+s1z2SdpCUTVGhZf8gyMWEJoKzY7RUYrT2qiWFW5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pXfJlPn00Ee4R1bjyWY+94pyHb6aKlnAHCG4D9Y7WRw=; b=LpU9AYbfQ7P44GcTFpdf3Scy/khrokfVOynpyBteBGNhsqCcBELJp9LegTJWBMfgT0HBt3M6qePsrlSzO1NaVqYKPsvHB0DbVGCIgJD6ip/tfUfj4I5GlgqUhL18t+cWomUUD60kuP8X8/hd0TZyqoAJm8bx/aHCccrgRuW4UUQ= Authentication-Results: linux.intel.com; dkim=none (message not signed) header.d=none;linux.intel.com; dmarc=none action=none header.from=synaptics.com; Received: from BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) by BN8PR03MB5041.namprd03.prod.outlook.com (2603:10b6:408:d5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Thu, 13 May 2021 06:40:03 +0000 Received: from BN9PR03MB6058.namprd03.prod.outlook.com ([fe80::308b:9168:78:9791]) by BN9PR03MB6058.namprd03.prod.outlook.com ([fe80::308b:9168:78:9791%4]) with mapi id 15.20.4129.026; Thu, 13 May 2021 06:40:02 +0000 Date: Thu, 13 May 2021 14:39:53 +0800 From: Jisheng Zhang To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Chris Wilson , Jon Bloomfield Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ville =?UTF-8?B?U3lyasOkbMOk?= Subject: [PATCH V3 RESEND] drm/i915: Fix "mitigations" parsing if i915 is builtin Message-ID: <20210513143953.1f8a82e7@xhacker.debian> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Originating-IP: [192.147.44.204] X-ClientProxiedBy: BYAPR02CA0056.namprd02.prod.outlook.com (2603:10b6:a03:54::33) To BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from xhacker.debian (192.147.44.204) by BYAPR02CA0056.namprd02.prod.outlook.com (2603:10b6:a03:54::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Thu, 13 May 2021 06:39:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 35301b51-949f-465a-f0b8-08d915d9eff6 X-MS-TrafficTypeDiagnostic: BN8PR03MB5041: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OehM+pyZrDIb3o69uOfbZIfBMXtmD5rvrsrCdIeA9VZvtwpiKGhO3p81nYP3X2DKZ+voTUzl3h6Da5CTQX70fsINLjNDliuf45SuxPm0v0YQoIUmqpLaQ9nGfOqZ3wJ6kKYfRdHxWkYwwS4Ppc7UN+oMB2IAzSD3ITDHmi3Ao1J7lZgiSJspwYCWobQ0HOBc6rXdJlE+tKdtEZAjcofjspPtyiSqWajTtS+P5+qEyqbb5KUCBu1HAIAxgCSPQMkHJt9gHdn1DbYPptKbuJCFjDOxWy71KGRmFlxGmUFDLJASGNOvy8ZF6NEETPFmkM92WMpAo+gI+Lc5BEoYlnAhnSv7r/3d/yHnjezX+0aEg3gQ/hjogHYjpmCM/zNLpKkWmUtpwn4wWq/UhelbQtdTNphqBFgfEZKK0qQJIetnesfHz6houVRMYWV3+GGrIY9DKBo0EaCSfFY+kNmoHzXkDohGx8TVAiHxjM+V6oPXmaaN+QKMmQpxcYKaxr2pd8vluVnLjnR+aYcXdtTsl8WL5nFiWHRIvy9vtHjWxb3GnIyKtW+tzu7wwtXeQdU97G94aVjay0jjLn5ndlLgP7J57o7qU678wDfBuAKuNmVJc18fX7x9sExJuCxBaLU2FBeGD/QG00sgo4zvAI5rBXnjhenUOj2RxztL/QmtwBXl5Lo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR03MB6058.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(136003)(366004)(376002)(396003)(39830400003)(8676002)(86362001)(9686003)(66556008)(7416002)(52116002)(16526019)(66476007)(7696005)(478600001)(8936002)(55016002)(38100700002)(316002)(38350700002)(956004)(2906002)(110136005)(83380400001)(6666004)(26005)(1076003)(66946007)(6506007)(4326008)(5660300002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?ouWjBckXTmvZAPe8F+0YSf1IWG6QofDIcyST66l08KrFDRiGn8S/ZhB11p7q?= =?us-ascii?Q?2pPGbCjc4S+YKqYLFsZSKI11Xpwc1SAl00wfnTZFs90beDvNLFjXXJ6E8tlJ?= =?us-ascii?Q?yjrxabutLeEJvWRDOuNnfG/cJNsqKsWwgG/kJVm/iivi9F7GpBQ2Bxwd0I2A?= =?us-ascii?Q?BRK0NbfllB8b6VZ4x9ZHQgvzRZhnOpkhmJvJHcHOMUxfYCyQhQtqIYfU/ita?= =?us-ascii?Q?NFF6/vaPIpXnSfpygsujZdfo/q7OP0Bu/ccGm8CIN8WNmeqeInZP/KTjDig2?= =?us-ascii?Q?aMCO9ELLTLg0dx3ENCAs8Qiby+yU6XggYTLP7M3VRX1LQ4OPvydIdFIznQKx?= =?us-ascii?Q?Gxjd5m/F9tPny1km1iSjkQxGNp4ux4dunB/StDXDPQGQBQf5rGzHVfoISNjO?= =?us-ascii?Q?eOYQUTCNxInHi8Hh2CkCBSNGiza0vz6OIwcXIzDjRqSiMVrNQ4PFiqmjgESC?= =?us-ascii?Q?lN6Keb5jMLM2lJ5SdpDkR/h0NleyzZdwbB2hxlq71+Nnu+CRYsJWI3AUWSDX?= =?us-ascii?Q?nAAz5dmSnyFQD+uNnC7FEng2dmHhKgVltidBKWuF4jsfKXSMw9hTxcy8xJQu?= =?us-ascii?Q?Rl4st3LtfkkOMk6bwt3x1mKyY1ju9IBiZ6zSlGTUVTW+hV3A6NFXjNR/lcUM?= =?us-ascii?Q?HRHLhp128JE7ai4Wbt23r5yx5jWI8CZ7158lk9zdLlSwkwzpE572xNQo7LwV?= =?us-ascii?Q?1+7Bsvm5oFTQ1v8J3DiOOo5xS42dBR43It74BJXzYUdPW4LdLsT3q45uPyyF?= =?us-ascii?Q?R1OjxT1ot4MdXH6MMbfYjTyYd9X6b5fF1Tw4HUYbe5KMms+MqkflcYNWT32o?= =?us-ascii?Q?WK1Wo2sjndgh4AHIC8kDO3yCjIoHBv/10THi5tSZzPLK5WiywM7xx7gaDm1r?= =?us-ascii?Q?0Ni1+ujLl6vgpcKEtc9uVy8YtxpeKcWbZo/S8gRtyHgB6i55ektW1qblddfh?= =?us-ascii?Q?4diAQSWuB/3yOBN6KG85ksbcBy1olZi+vxYFOl5z88Qu5uz+ArdIx0/YC5Zj?= =?us-ascii?Q?qOpLM2l+r0uSGdnQMD4QbW62wExiwIRByP0aspc8HOxSLYqaNNz4OgnlqhXJ?= =?us-ascii?Q?6KF7pVVj58zSjys9ESgDf2p9ku894jbylt9yWjMs6tUsDAOngo5CuRyihM7X?= =?us-ascii?Q?4p9zSXvO8T+NO1kJco/8vZiXRGTKm1Oe1NO7MDEd/h3yHJjvy6Is5eMfhpsE?= =?us-ascii?Q?yWaL3OkbaqtSpCzhFzoucb4PTIgFL9VS65QZJHc9Lz6XTI0eVqTZ/HFp/110?= =?us-ascii?Q?c9LVEap8BBwpLXrOr774ivBq6rtr8XiUZufeAZU+4R+of9NlLiRO7tf+DilA?= =?us-ascii?Q?I1esXXuzEiyDx6A2jGcXXkZt?= X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35301b51-949f-465a-f0b8-08d915d9eff6 X-MS-Exchange-CrossTenant-AuthSource: BN9PR03MB6058.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2021 06:40:02.8168 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tLiWzjiqSp/cL4Yh89nHUrUNuB8cLG//DIbPxaX2PlsrHRtzRp1XXbfkTYoi0mRNjn3UDwdylMN45hQ77Mp+eg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR03MB5041 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I met below error during boot with i915 builtin if pass "i915.mitigations=off": [ 0.015589] Booting kernel: `off' invalid for parameter `i915.mitigations' The reason is slab subsystem isn't ready at that time, so kstrdup() returns NULL. Fix this issue by using stack var instead of kstrdup(). Fixes: 984cadea032b ("drm/i915: Allow the sysadmin to override security mitigations") Signed-off-by: Jisheng Zhang --- Since v2: - Use strscpy() per Ville's suggestion Since v1: - Ensure "str" is properly terminated. Thanks Ville for pointing this out drivers/gpu/drm/i915/i915_mitigations.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_mitigations.c b/drivers/gpu/drm/i915/i915_mitigations.c index 84f12598d145..70944764a77e 100644 --- a/drivers/gpu/drm/i915/i915_mitigations.c +++ b/drivers/gpu/drm/i915/i915_mitigations.c @@ -29,15 +29,13 @@ bool i915_mitigate_clear_residuals(void) static int mitigations_set(const char *val, const struct kernel_param *kp) { unsigned long new = ~0UL; - char *str, *sep, *tok; + char str[64], *sep, *tok; bool first = true; int err = 0; BUILD_BUG_ON(ARRAY_SIZE(names) >= BITS_PER_TYPE(mitigations)); - str = kstrdup(val, GFP_KERNEL); - if (!str) - return -ENOMEM; + strscpy(str, val, sizeof(str)); for (sep = str; (tok = strsep(&sep, ","));) { bool enable = true; @@ -86,7 +84,6 @@ static int mitigations_set(const char *val, const struct kernel_param *kp) break; } } - kfree(str); if (err) return err; -- 2.31.0