From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8908D472762 for ; Wed, 5 Aug 2026 13:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.69 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785937357; cv=none; b=FaRt24csXBWKMH5PExDQ2GnS4H2IYpPZWXkJvaYwU7FL5w1YLSMxPuyKWuQH5wMef4zSIBnKDWeHSMhtPLrTr8hBxzId7RjhjREdSkSJSvIlmptnKpUUv/lb0fCNf0rOusTINw6kkqQoxdZh+YWOs8DCTIRadyWFiawURnMOfS8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785937357; c=relaxed/simple; bh=RVTieBkl5PxGC5DHHDci1txVVRWbP0oOgHybHdzRmuI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nbOjpDqRCbKeKOUeINY4lYdO4T0RyEKTX7dMs3cVkdFJ1F0o6IOWWxcWADbYMXOMM/SazmwYHF4pZM5b7u1DXyUMF5i81TGT2iayYJjEigIkWt5O2Y+zCIdQqOiiBiUTUFrLahFPfHXoU0GOsa1OYPlooxE20Z0dh74XutYRtHc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--thaisonphan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZXQmQZsT; arc=none smtp.client-ip=209.85.222.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--thaisonphan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZXQmQZsT" Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-97762b21ba3so738657241.0 for ; Wed, 05 Aug 2026 06:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785937354; x=1786542154; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=RVTieBkl5PxGC5DHHDci1txVVRWbP0oOgHybHdzRmuI=; b=ZXQmQZsTRLc6gQeRCTYLRp6VMUABysBPaJSvp+bQ/Vm4f8LkXMN/m9ZSfdsPHgda3G UFeqP3C8hSKsWhWVpNG289A5PaPt/Wb1dkbins4+I887l5JDM0B9mnZYStYO07R38e+B NxFFw/kMFxHjmnvrVFKH4A6912It/Qmyidc0bt5LH/ZBUHd20iYUSPZ0xJBm8KwWQcnF HJ3ANwZU8Jsaip7ebPaF2A4NwDdLQrfcCIgmS/Vqcp5yURBl4UvVRufCJqP/iBDnQirD q3EkfwayhBRCWkRxi9LPyAQNL0CqNy4OxCep2SLwitFPY2apYzQp/8wdVT0ggzX/wQrT uyGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785937354; x=1786542154; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RVTieBkl5PxGC5DHHDci1txVVRWbP0oOgHybHdzRmuI=; b=BmZAzMPaOWJ6Io0NrcJWkrPkNADEGaEdxw/vwmcRKjDNNxBeYrY09stCvlIFdmymqq D79R3/LwG+zkAPsJRfDNdm/DIL3tgAbcNmNhBvEfAUrjcHqJOsprUdKGjuHU+W9PcBfH FgaiGSQ84NcMakA9Dk4mrfLO2J6DzPq7gnBpNF5zvtTl/U2nb/jFLEirj7EXe/PA26sf WU+TGr35MFlgXDLW1IJP7upDQ4dZBnuIh5qmlxSrHAXlRD7RRYmW+Klb6nuBVJ75HjvD RXrik5xkG+mDoe3aWTVQCHMzNzb/wjaepLYlxdG4Gp43ghtBOFrQaCESmLHxUx7dDdBA 4tlQ== X-Forwarded-Encrypted: i=1; AHgh+RqZQOnF3q7p/AmbXgfDf8cNvFuULCRUFqp3o30pWauwUcf0wnUqoJr/SJ+ScjfWaAfaPhpmK8OWP/6cbMs=@vger.kernel.org X-Gm-Message-State: AOJu0YykeJ4VRL4W7+PTZF2DhQKk5N3Sd2jGmNavIOJ/dK97JLzRDtkr Au+Dc+eMuAJdPzraVa2KdrRhBCbZm8r3a1ct5JOHL9E65Oz6KnLGLVrdMjsImtFxoAdtVFmG5zC TX2YtrbVc7PWwjmWGUGMtB7KcBg== X-Received: from uabdu25.prod.google.com ([2002:a05:6130:2819:b0:977:cd2d:d150]) (user=thaisonphan job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6102:f8a:b0:738:1ef6:51b9 with SMTP id ada2fe7eead31-760e80f94ebmr1897347137.5.1785937352795; Wed, 05 Aug 2026 06:42:32 -0700 (PDT) Date: Wed, 5 Aug 2026 13:42:32 +0000 In-Reply-To: <20260804143359.702b0237@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260804143359.702b0237@kernel.org> X-Mailer: git-send-email 2.55.0.629.g250fe7f194-goog Message-ID: <20260805134232.3378922-1-thaisonphan@google.com> Subject: Re: [PATCH net-next 2/2] tools: ynl: check alloc fails in generated code From: Thaison Phan To: kuba@kernel.org Cc: ast@fiberby.net, davem@davemloft.net, donald.hunter@gmail.com, edumazet@google.com, gfengyuan@google.com, horms@kernel.org, linux-kernel@vger.kernel.org, matttbe@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, stani@google.com, thaisonphan@google.com Content-Type: text/plain; charset="UTF-8" > Silently eating errors in setters does not seem great, better to crash > and make it clear than things are not working than have a silently > misconfigured system? I was thinking that the user could check for NULL in the struct field that the setter was allocating for to see if something went wrong, but that is probably not ideal either since a user might assume with the void return there can be no errors, and I didn't realize the field is not guaranteed to be NULL when it is passed in. > AI also points out that setters are preceded by a free (in case we're > replacing existing attr, multiple sets on a single attr are allowed) So > if alloc fails we'll end up with NULL ptr and len from previous > allocation. That makes sense, so we could have an unreported free() on the key someone using the setter might think is still allocated. We could maybe delay the free() until after the malloc() works, and maybe we could return an error code in setters that allocate to let users know something went wrong. > Maybe tackle the setters in a separate patch, and keep patch 2 scoped > to the easier case? That sounds like a good idea to me. I'll make v2 only tackle the getters and look into a different way to handle the setters. Thanks, Thaison