From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795951016; b=zys7gp4a2H41WN0ynwv48CtbcMgKV0kr5dLU4Z5eUsFKXWPKJxaea7YMz2TnYBtlJ2Wd kpJ0udy04LB+fvcLmaPPDJFhad1PuEybJjwNgEpKpPOAxQ7cf53DNGg313ZvTRMRjRCI2 TH/X31uGxQwC+eFxYDX4KoyemyxR4vEj2gtKGE2d5qPYrYysaEZ7v7vxRygBoVYXi1aPj dlFNmMWxXXal19v2IAHSWMG5SCAxGRttSD2XTQKcJ8OEdyaWcD4M7Vwz/JM8IVVSA3AOE antzBxyMONKtck2cqrmra9wVDOD7nkcN8OghGSyLsYYrV9+B1E1e8Of8suqhUhoAb5A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795951016; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=rt28tDOGdfhgvRT8u87hiGV6rWh26t7na0x94a3usYo=; b=oYv90zSsjaCfCJ3q7DItWUqDasiwmTjEt83WXtmDUJmt9vsUve9EbNzmlvWbBlaKd9XR VwDqpveyEumOtS38cDfl7wEjqAhlLxQYASo3lAisydj0BlWCB0KQr9j8Uo7CLhW4Sorob 1DjbWOE2L//isIvhDt8I9gMsTn+G7SHRXfji0ig3eiQpU9JZ4skfKXdQ7SamRNtHGB3tt JfgKraCI9Gep57o+Mu0o8CO+gLdAcUg+kM0hugYBXDNIWtmehU/26B2HZ+Pvi5ZYHbiM0 uRrBCIzvGgQbfyq6BzXdZ1h/2rbul9/VoFRmylM+nATx/kFbqyLpqy4UCXYbA8wJ7jQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="OWj/6whP"; arc=none smtp.remote-ip=209.85.128.70 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4A7D606A31C for ; Sun, 29 Nov 2026 11:16:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C4A7D606A31C 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--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=OWj/6whP Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a35e1d2dddso77503505e9.0 for ; Sun, 29 Nov 2026 03:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795951014; x=1796555814; 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=rt28tDOGdfhgvRT8u87hiGV6rWh26t7na0x94a3usYo=; b=OWj/6whPz23idrg48KLqCv4yXjSaQ+EJMHKQLpBjAfOhJiNjgggdDlCgGcVj3O4yyh kI3gtPbK//+H9FgyZEzj4OSB67no1Hu2YSEg4pzKcy4PnxWJVrJr79OxS44epW4+sZ5g cZ2ZiydhHzr4rlSbtf+Gx0GRUKY9+MkTgxVxH7xkaZcRApBMlE70g3wxi8weFKz9ypKJ xtKSAqRnIZC994BmkJ3VB8JnyZ/56LP7P6hl49gFYlkX0WQ2irZaD2hvDF4Bk4ecjrvN X3lbcN3P8P9gwUhdz6oK86oYdT4vySj3FL1duyMYdw+LLOBka5ddSKdU6OJvm8R4MlI+ j4HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795951014; x=1796555814; 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=rt28tDOGdfhgvRT8u87hiGV6rWh26t7na0x94a3usYo=; b=SON+dD+FG2lwifAGv05OV15Qk0P0Hsm44PZUln1PfKbH/pnjEO9gjg7b380OO16pae oT/NcWDxU/gyapBtfkKFKzfHXvugYpF4InKlZZgX26Gq+ol3McjTGPSx3loouhIUAPb6 MP0xz/xARf6t3Dp8WrQTxeMOvm0Z5cygAnRqq5ROLhsv2n8LE7plGSlFac8Y9Ps5UKTW FIo3qQhUVos4/GV2hRZpcleBzR6l0FsUDA70XIyrAfgA90SEpgocjSVzb+UNB0NTL+2k UJGMXpz+UIL4QKSGqMKUwgFY2jh2AK9U6Td5om+UoB05g4ifUOa+JC+rHR83pJHyJmei dXSQ== X-Forwarded-Encrypted: i=1; AL+hErHeg5MVrBgbYfJo9zbSFwlL6i13HgqmdrG0yPzWPInBR7YLcINvRJEQG3EZNO1h2Xb9JDyFUZr7jBrR4sc=@vger.kernel.org X-Gm-Message-State: APuU4Z+1EZ4HEFu7/2+JpQHYH2+VPFCeYCCuK70RzWZtndjTYjBvjj6N DG6UEk039zmAzGM8xrJBeOj8kmeQyGi02mFlBmkU/FrjcyByHS82labU/IwTY9edPwj1jp8v7Wa 7R1pVIU/Vlz5E1fOvpw== X-Received: from wrf5-n2.prod.google.com ([2002:a05:6000:43c5:20b0:4a3:4620:1d69]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3b94:b0:4bb:6f41:39be with SMTP id 5b1f17b1804b1-4bb8880ca3cmr735385485e9.15.1795951013899; Sun, 29 Nov 2026 03:16:53 -0800 (PST) Date: Sun, 29 Nov 2026 11:16:52 +0000 In-Reply-To: <20261128153529.143070-1-adhyanshverma2010@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261128153529.143070-1-adhyanshverma2010@gmail.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261129111652.1264306-1-aliceryhl@google.com> Subject: Re: [PATCH] rust_binder: return ENOMEM on shrinker allocation failure From: Alice Ryhl To: Adhyansh Verma Cc: Alice Ryhl , Greg Kroah-Hartman , Carlos Llamas , "=?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?=" , Todd Kjos , Christian Brauner , Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Sat, Nov 28, 2026 at 09:05:29PM +0530, Adhyansh Verma wrote: > In Shrinker::register(), __list_lru_init() is called to initialize the > list_lru. When it succeeds, ret is 0. Subsequently, shrinker_alloc() is > called to allocate the shrinker. If memory allocation fails, shrinker is > null and the error cleanup path executes: > > unsafe { bindings::list_lru_destroy(self.list_lru.get()) }; > return Err(Error::from_errno(ret)); > > Because ret is still 0 from the earlier successful __list_lru_init(), > Error::from_errno(0) is called. > > Per rust/kernel/error.rs, passing 0 to Error::from_errno() is considered > a kernel bug. It triggers a pr_warn! warning ("attempted to create Error > with out of range errno: 0") and falls back to EINVAL instead of > returning ENOMEM to indicate the allocation failure. > > Fix this by returning Err(ENOMEM) directly when shrinker_alloc() returns > null. > > Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver") > Signed-off-by: Adhyansh Verma Reviewed-by: Alice Ryhl Alice