From patchwork Mon Dec 25 15:39:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 758220 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp2709868wrw; Mon, 25 Dec 2023 07:42:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEm+ZEO/YlCQpJkTrP7DeRYyLemuca3/HanY4pUZ+VbKRDiaXfG2Sc+O9SYeVLCU1EnrQt8 X-Received: by 2002:a05:600c:35d4:b0:40d:50a3:cced with SMTP id r20-20020a05600c35d400b0040d50a3ccedmr2331263wmq.9.1703518929087; Mon, 25 Dec 2023 07:42:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703518929; cv=none; d=google.com; s=arc-20160816; b=xWVAmc7R/2DkoWvmEfzYvpJDqY1cVBAC8A36MxE+UdHYB9iCXoYfbUAR5xT953n/eC BHeKOJJTz3if4VQdBWVu6ICtbdjwgpVQfKe45XpP8pLugdS6CY6BEeU6T0tiV40fQ+Y+ sg3HjYcGpF+q27gLYp67l17OMJdBirvmohSz5LeBcQ3aPr0y+QLlqIVz233b1xhrREAT l59j95rGRHR7G9SiTiHVq3/ULi+6Oh/kcpJFgXVtMqp8BBbXunSv8wi9i1k6EpwPI6BZ SRg/fCUpbN/M0ves8sbPoqC5cguB/yrlSpK+U5bM+DzPNesBDvX/0NCtj+YWNddgHEjD bvQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zsr0zJss76jKia1cvuV3LBXuFsGHY7LZmxXVF8UwBkM=; fh=al8TO5kxNSCLdK6Wct4/S1Ky9QCKGaknFfrx/Rr/20U=; b=y6uuOPhk8dtCr65cGbw2Dm/1vbilcV+1mK19+7tHkr3FM1zMs60AT81WutnZ21CM/4 PAcSiXRiqYfswbcBzLS2n3kRhQ5Gi1KIRdyyHfpDmU7PiiJHI+HcLgzKFBmcLD5Py2lP r7zNRX32QgfIfKZrf8FYFsV35UoTuTW4+GdTIAm/dtiiB0up4qADkx8OOmYAXmb4glf9 A92gQje8eLAW/4GzKLI5VcXcMsYlhd1GAct9o+37B5QJU0l4DpN8xx/3jZkirpquRj/p 2TeiSPAG/RljA6+vZn7wQVzZRvLsfWGAvXCwfHgA4y8WvC2OpGTXZb7e5d/DlaR5ZA7h 4Fgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N64ZV7oB; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id t11-20020a7bc3cb000000b0040d2924e7a4si7104740wmj.149.2023.12.25.07.42.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 07:42:09 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N64ZV7oB; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3793F87646; Mon, 25 Dec 2023 16:41:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="N64ZV7oB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 736CA87561; Mon, 25 Dec 2023 16:41:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7A79C87721 for ; Mon, 25 Dec 2023 16:41:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.uvarov@linaro.org Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3333b46f26aso3754467f8f.1 for ; Mon, 25 Dec 2023 07:41:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703518909; x=1704123709; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zsr0zJss76jKia1cvuV3LBXuFsGHY7LZmxXVF8UwBkM=; b=N64ZV7oBxqV1DxRAuO1gtDYURgYGWB7Bc3mHQSUmLeKih5sC+hVW/LzgnLHZbjuN5q as0sSEzbw0hX/OOnyACExCuKppCqQvtbXjXs2pqqHUjNkCdAaLAiTF7iFFW2zKJwsAD9 jRbZzwpdIe4D+ND40b4aA2R+toZnjVkGfeiO7/MJMgjrWRbhK0zEp+/YkQcQG5MSjg5O g6jh9T1/PTnMAhXkC/S97arcIPIOR8hvQBVjAUj1CL/t9nPUHEd+dnyoHsAW2bIvxHCA +XGGYyEPNsTaoWELjCyLv66CwkAlMwuhaEqXZvMyzKl5NNqp6WbKn5A/i8sDFznjvjcc k6Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703518909; x=1704123709; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zsr0zJss76jKia1cvuV3LBXuFsGHY7LZmxXVF8UwBkM=; b=wuRvQsK0hXG4P/kbYvNT6lQorzMzMe579GhOkLqraKRUDaaniohdpK4gF55TILzQ1z 5Yc7XNJOWdw5hz9iU0i+M3IACyeFMr/02JQka675SL83ynkanhJwggVnDE7LVP/mufpi sHNnPPGHdSBMjFJqAhUtT3zAZYx0/llus0NzNjdMuZ55oqSpNL8O9CV0C6+vuOl2S8ol 3tQoCfk4DpDHDj+5M5ABiTr2qHUG/fAWITEUDXNIuYL+SkNMTGSLdE5YKq4XBwrwkq5y bdpl9WYsE5DjMZ2ZKT+V/219GJNb7MvveqfkSFWddfK8EIFGt6C6q34Aipu71lEeVZB3 aazA== X-Gm-Message-State: AOJu0YxFL3tTI2X3xn12bnAyKBF5ZKGDK97Ml6BSygGFzE0dpm8dB941 NeLePwFPI3hZp5+JLRCs5u6AmN2ASQJE+q3Xy9YaIcc2efw= X-Received: by 2002:adf:e881:0:b0:336:737d:4b93 with SMTP id d1-20020adfe881000000b00336737d4b93mr3233669wrm.46.1703518909253; Mon, 25 Dec 2023 07:41:49 -0800 (PST) Received: from localhost.localdomain ([45.82.14.220]) by smtp.gmail.com with ESMTPSA id a17-20020a2ebe91000000b002cca6eafc44sm1425644ljr.113.2023.12.25.07.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 07:41:48 -0800 (PST) From: Maxim Uvarov To: u-boot@lists.denx.de Cc: simon.k.r.goldschmidt@gmail.com, tien.fong.chee@intel.com, sjg@chromium.org, joe.hershberger@ni.com, rfried.dev@gmail.com, bharat.gooty@broadcom.com, rayagonda.kokatanur@broadcom.com, trini@konsulko.com, Maxim Uvarov Subject: [PATHv2 2/9] net: sandbox: fix NULL pointer derefences Date: Mon, 25 Dec 2023 21:39:22 +0600 Message-Id: <20231225153929.8284-3-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231225153929.8284-1-maxim.uvarov@linaro.org> References: <20231225153929.8284-1-maxim.uvarov@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add additional checks for NULL pointers. Signed-off-by: Maxim Uvarov --- drivers/net/sandbox.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index 13022addb6..d91935e032 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -65,6 +65,9 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet, struct ethernet_hdr *eth_recv; struct arp_hdr *arp_recv; + if (!priv) + return -EAGAIN; + if (ntohs(eth->et_protlen) != PROT_ARP) return -EAGAIN;