From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D98F7C4451C for ; Tue, 21 Jul 2026 10:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WcMg8gRHQD/ooAVrju9gGD1pMsAplsvvVTlyRfYUrI8=; b=jpsGQUWMVOsg6H l0NqVKrlnRckuZQak4/Mcc7tXNGL3D3mzlazf77ntbhj3qyDPpiah72Z0dKlm/uJrj3pHBS92crzI LRBd7NxlwxRxuz8S1ovNrnaqcSf2Scg59NFP614ROu5QvZOU8JwWOnOEhawteeeTBATKrYzbDBdyY OkFCqaaJsgeDEAO/rMMbYwxnopUSOJsjt0Se39Jlw1f8bC91Ba/ok/nd5ePzGf/OPLE4cXVPtdU7O 9Gpf2K1M4i7QkTbFZ6oJ7FJ1nkrauFJyYx5YzVxSZ6Japk8JPUnDo2OZZqjcIdVtlbFwBYcpDAe3s URsTUaQx1WmUYFblHCmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wm7wr-00000009Emh-2CTI; Tue, 21 Jul 2026 10:43:41 +0000 Received: from mail-northeuropeazon11011013.outbound.protection.outlook.com ([52.101.65.13] helo=DU2PR03CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wm7wp-00000009Elv-3bQm for linux-phy@lists.infradead.org; Tue, 21 Jul 2026 10:43:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=huI2HSSy0W9DxqmUUebQQpyTCaqpMHnErMSpv955+bMwbtam9a6ykiKQSRH2FaIUF7hCmKeLqtTxcnmij28MY9RhUTQ7iTY3C0e5gmnO0sNFC+C67QzCI9XPNerre6cdGnEtJkqN/1vCzDnSNWUWT+vNGRktDDjvzBtIZAo/ulvE7mZ8YWNzmj61HkmcWBD5Mw6mRO0+L8owCWtr3qnaULb4OBgfnWM1ZLWtOsFoQna3bRI57+A5nJdQX6/eEwRgyShWyMy33Dad5bJgq8BuXIvCa/oT6/dVxf94lIuOd3vEwo9eNz1qI/pSgcmso9I05paXID8wfiDasmVx2Hm7DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oTQpKYbw0pLxVuZskOvw8nheLjaOo4A833bSVrtlBGA=; b=usrdpiQAo37qjkEOMnqohbF2C4AuEzxvGuVzU6CsCDe8fVMMeOXLbkO51b8Cjj2Momy7wXcaexZ4yexd6DpbynJqH9Yj3BC9AI3w8aMnNRfCZ+T7XosFSUGsU0eLaMS2ga6DxV8LmbgODESelMprQrd0/uHmlisvoEab8zltciQL8vGi8fcMqStlY1xh8oHp9PZ0r/QfuUD2CkSuErIKYnfdBrk2oRg9OMXgrl7K+fxxMYTARVwThHcWxP2W8G7GzdYtP92RB3iNdJCfKVXpclfAsC1tt37cfSiR340kxXtk0KC3+7Dsoc7btuTpLj5VTlyZli80ADYAjWNbbr7CkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oTQpKYbw0pLxVuZskOvw8nheLjaOo4A833bSVrtlBGA=; b=bL7vBGyvhrt8b3wHemvW8Zh56X+XogKtCcdrPxTYvMzRpEPDSeTzzkIZKQky8caUtKQiKfWtbo9qrY//BRodKsiatr9ciXd1PJU+FKOwtP9khVXEDNPAgQUeS7yznl4kWx43f6K7fFO9HxPfqQI3Qg7XlIDSnZQli7s4ZppvpYROlGvwZAcV2ouwd9VxT28jUXw3KhmPttw7YBdFw0Xs5TUvSO7GuQTjHPYfur+k2DGE99sb401yZf/Rq2rD/u9wQoGr18MbOjiOghueBIvtY/9+YNEvFql0+PEvypR87NJ2/mNy1Xa0nbyt9Pl+yt7UN0xsOw/oU1F6bphLhSXNsg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6900.eurprd04.prod.outlook.com (2603:10a6:208:17d::10) by PA2PR04MB10424.eurprd04.prod.outlook.com (2603:10a6:102:419::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Tue, 21 Jul 2026 10:43:36 +0000 Received: from AM0PR04MB6900.eurprd04.prod.outlook.com ([fe80::7fda:8431:ca1b:b023]) by AM0PR04MB6900.eurprd04.prod.outlook.com ([fe80::7fda:8431:ca1b:b023%5]) with mapi id 15.21.0245.009; Tue, 21 Jul 2026 10:43:35 +0000 Date: Tue, 21 Jul 2026 13:43:32 +0300 From: Vladimir Oltean To: Michael Walle Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org, neil.armstrong@linaro.org, olteanv@gmail.com, linux-phy@lists.infradead.org Subject: Re: [PATCH v3 phy-next 2/8] soc: fsl: guts: add a global structure to hold state Message-ID: <20260721104332.e65ma6tiwoisgo7m@skbuf> References: <20260720133642.136324-1-vladimir.oltean@nxp.com> <20260720133642.136324-3-vladimir.oltean@nxp.com> <20260720135049.8AC231F00A3D@smtp.kernel.org> <20260720140139.dmgysphpse2jf3fi@skbuf> <20260720145724.acega7erguyufxd3@skbuf> Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: WA1PEPF00005B8E.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d8::62f) To AM0PR04MB6900.eurprd04.prod.outlook.com (2603:10a6:208:17d::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6900:EE_|PA2PR04MB10424:EE_ X-MS-Office365-Filtering-Correlation-Id: 828070d2-83bf-4a93-021c-08dee714eac6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|19092799006|10070799003|366016|376014|1800799024|56012099006|11063799006|5023799004|4143699003|10067099003|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: jvmhKzH3JYdGDmfORSPHx4LSn+uB8zhDMRuf4f9Y+U5UNbkqACy5yD+PMW54zydK/0ExpcUmqx+H1JLZioZO7QMqPnOos7lY6czGL3pGWEJPzjWI5gRhauil5EUAr7JEiy8wW6MSxtJo1ukiWkgMVI3Xnz9qqqN872GzWvuuURb4CWT0gYaVUyGDWMmOtSCUqlbpw08dJV793fW8r7ItFTQykL+sQPwSdiy6Fwc9HXb411aUbTrXz+XMu5Ejw4T2GaoOnVx2G4Yv3VELqFIXyu2ZzobMRUw8B68vXWtT802akAdy9EpdkTpEok4h+SeFc8iHtUAcrSxZpp5h/aRPiGzOZwOZI6GmR83HMjDW0GVIgVlLMw6YGZQ8mkeuEZ760vmBopoCqkGpmTMJGp/SeAj52Yb/V/otwtajf9s01K6PRLGYqx8xB4bNSt6/TYwiq2ntAAW0bl9RNmGxGfH81sAwCtplme7wR0ccHfzKuiFqgovk1QSG1ATqCQesBZGFyJgsX1jvB8yXmgw4puYW5SXGLwk1DxopDKEUXQ72DI8VBh36aLXYjMS1Dcju6mrxITCd0VapVJuw/X5ojW6O4ZLWQOy9kXqRzjZW94yDf6b/rQ112ZcudYtnqHc454HzJZN3zAFJBgs7ulv1vX42tAAT4JBBq3zvozGn7I26V9c= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6900.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(19092799006)(10070799003)(366016)(376014)(1800799024)(56012099006)(11063799006)(5023799004)(4143699003)(10067099003)(22082099003)(18002099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?vKWvRt7DwYoKqBupBldghbcFdAyZwLM/smRKJp7mOyTElaRFc7O8l89tmefN?= =?us-ascii?Q?DCdt63SdybceguqVzKk1Zb02RJbFcLRtuM9SenHpn4odF6DVPtXAHFMo6TmQ?= =?us-ascii?Q?28h1+B/QolbCHB95mKCyjbYOkDmpa1eXR0pLUKBZn1NE724ibd4s3dY9RMx1?= =?us-ascii?Q?yIOldJjeJ5phsnzGFomfA+mQ3cQ1twdbZ7ZTnqp2edlihvXBdmbLB/lTtH0E?= =?us-ascii?Q?9SVOjyec0G7fNLmFTgOlEIagqhpJK0hoRkJu9Gmy5+aq22Ej708Qaci3ct2R?= =?us-ascii?Q?Pih7eY8BUu0mefTr3jP4UzQVxKR3p2nU8gqT2xePyTtfVTse9TLAItVNJk47?= =?us-ascii?Q?WaoePnrO1GdOp9snNgpOAh3aY3N+o4ea9DxVWfYS8sTu73GxnaxfXN+9I+XP?= =?us-ascii?Q?n8ZzpDIxH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=?us-ascii?Q?qJ2ESpJNLHacZ7gBooTYPpDCaDQhR3M9ZWBN5lOBJ3yafKp8leYdMiQHuqSV?= =?us-ascii?Q?TeFHKzm7sMOcvhDQBwJIRholILbke6uPHyvyJL9vAVjg8rwjh9rJ+7V/7C+b?= =?us-ascii?Q?3GFQ6qDUbgLvLB7TBt8Zwg/ZNjYIzUxfcMe5pqPCzoFsPlfbhJ1I0F0mQyKL?= =?us-ascii?Q?IrmHVFn26FXoTjsWwo/lGUofrLf7DWprRJpXGeFfHDPC+LPY19SQSNSKXhXh?= =?us-ascii?Q?LtFSFjOE8noefVz5Rcm6bWTeqaZEatc6T6A+bpmgzJc8E1l3uswkh4rpj0Jl?= =?us-ascii?Q?8OxiCAvNm0qALWhTSEZb7UylQa9lwlFpP8GFu6q0bbP6GDqsaXdokqLq6aUw?= =?us-ascii?Q?R0mzLoXe6PIIuvo7gb6JPBO+R0zrZ5c7147qAJFSDtzkACohpvECE7l4ejXS?= =?us-ascii?Q?RMJUaLuvHkLNZ9G1h1hXfmMhlJgUWFuDMhK2ZbuiXWN/WWTU7dEXfIw+YiMD?= X-MS-Exchange-AntiSpam-MessageData-1: 97Zx0EshXB1tj5fB9heCcllfMwDE/c8BA14= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 828070d2-83bf-4a93-021c-08dee714eac6 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6900.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 10:43:35.9389 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZmDFTSIFYnWUavgy3Rxsxq0R1tk8aMu8yit3cIdniOgO8fWdrlI821kkC9/SLJV9023XTwszoP0ibHDS9FAEoA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA2PR04MB10424 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260721_034339_914370_0EF06F52 X-CRM114-Status: GOOD ( 36.79 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Hi Michael, On Tue, Jul 21, 2026 at 10:44:30AM +0200, Michael Walle wrote: > Hi Vladimir, > > On Mon Jul 20, 2026 at 4:57 PM CEST, Vladimir Oltean wrote: > > On Mon, Jul 20, 2026 at 05:01:39PM +0300, Vladimir Oltean wrote: > >> On Mon, Jul 20, 2026 at 01:50:49PM +0000, sashiko-bot@kernel.org wrote: > >> > [Severity: High] > >> > Will jumping to err_nomem cause a NULL pointer dereference? > >> > > >> > If the allocation of soc_dev_attr fails, the code now jumps to the error > >> > handling path which dereferences soc_dev_attr to free its members: > >> > > >> > > @@ -269,6 +271,8 @@ static int __init fsl_guts_init(void) > >> > > kfree(soc_dev_attr->revision); > >> > > kfree(soc_dev_attr->serial_number); > >> > > >> > Since soc_dev_attr is NULL when this allocation fails, won't evaluating > >> > soc_dev_attr->revision and other members result in a kernel panic? > >> > >> yeah. > >> > >> I tried to be nice and play with the existing "err_nomem" and "err" > >> error handling labels, but the truth is that a single error cleanup path > >> is just an antipattern that doesn't scale as code becomes more complex. > >> > >> Instead of having a single error handling procedure which needs to > >> carefully fend off from various invalid contexts from all the goto > >> sites, the standard convention is to have an incremental set of labels > >> which undo just the setup that was done up to the goto jump site. > >> > >> I'll refactor fsl_guts_init() to use that convention for v4. > > > > While I was doing this refactoring, I noticed that this code path: > > > > if (soc_data) > > soc_uid = fsl_guts_get_soc_uid(soc_data->sfp_compat, > > soc_data->uid_offset); > > if (soc_uid) { > > soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", > > soc_uid); > > // no kasprintf() NULL return code check here, unlike > > // the rest of the code > > It's a long time ago, but it seems to be designed be optional. In > that case a NULL pointer check was omitted, because nothing bad can > happen anyway. Either you'll free the string if != NULL or you don't > free anything. > > > } > > > > soc_dev = soc_device_register(soc_dev_attr); > > if (IS_ERR(soc_dev)) { > > ret = PTR_ERR(soc_dev); > > goto err; > > } > > > > proceeds with soc_device_register() even if fsl_guts_get_soc_uid() was > > able to get a soc unique id from the security fuse processor, but we > > fail to print that string to the soc_dev_attr->serial_number variable. > > > > I don't see anywhere mentioned in commit 786dde1e59d7 ("soc: fsl: guts: > > add serial_number support") that this would be intentional, so it can > > just as well be an omission. > > > > Is it OK if I replace the silent failure with a loud failure of the > > entire fsl_guts_init()? The code executes only if soc_uid is non-zero > > anyway. > > > > kasprintf() fails only for memory related reasons. > > I don't have a strong opinion. If you ever get that error, something > is seriously bad anyway. Thanks for responding. I think the optionality is already taken care of by the "if (soc_uid)" check. My intuition is that if the guts driver decides to try and populate the soc_dev_attr->serial_number attribute, it should try and run this to completion. -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy