Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp169435imd; Fri, 26 Oct 2018 06:51:54 -0700 (PDT) X-Google-Smtp-Source: AJdET5dn+9CjYTpHF5uKlF1RrU4uX8Y11Dw/ieYPM9+fFIgh3AiXA8Ww8u2WZHkicB45fofbiOD+ X-Received: by 2002:a63:3589:: with SMTP id c131-v6mr3530962pga.158.1540561913959; Fri, 26 Oct 2018 06:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540561913; cv=none; d=google.com; s=arc-20160816; b=snF17S3kpZ1muq+2crgpbZ0tzSQ/o4oQQbwco2coCiYouIgeWJ990QePNXOersZXvv qwnQRbPiQN0DyDBBRhGOOFH8kGwJUDGf7OtIl9RNlRPEeij+B1TGEWKiSE1NyHtGWUBT 8+gQVfkBOrGthUGUga+2wujKz9TdF0Vnw3fKK/SO0rzIRBaAWSYOF4nhcyU3WfnOjopG hkT0j/pCI9NWiLjr+Wv6g0u1CEauAAkDPJQY/UWlbFZLOeZdhGc3O/jCLy2WlAtegPH8 AO2AOul8v99mwFPDrTx4z9lRrEYBavfZhbiUEpfvyGxuaYfRkEq9Fg1tCScG4z5lCTvK Tivg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dsvI4qSNhUCCfAOJkMYSllS76rigJ/CcjnjSyJdY5+Y=; b=T9mV38bpd2/mdLFdCnKWs4d6NK56A4FKEP5A++NMujjgEmRo8xkSUY+3WT52kQRC5u Vc/vZss89BeKqWcpYiedb0kswZOKQnxnymAo0KiSOqHoFN2KCrdSrmCwpvs+XBRDl32U a9qNWwzHrSoHntgXoK1hIKCPx8G6NJBYHSbKR4bRK22wMQNyqc6Y7GSXV0PELCTIbxnT 83HVKsEEuaNgDFCa31hyVh1VhFYSajiBx0DlfYlABuvYhR5kWeTsx550Zwrv8PgceWQf NWjttWOD9s3yT8Q3tz3ePBStWR///gpf7csbIfhXjv4rBVbDTFj4UOvZQYWT53Q3RAlD wtoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12-v6si11137968plg.154.2018.10.26.06.51.38; Fri, 26 Oct 2018 06:51:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727551AbeJZWZp (ORCPT + 99 others); Fri, 26 Oct 2018 18:25:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:44790 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727431AbeJZWZo (ORCPT ); Fri, 26 Oct 2018 18:25:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8398EB049; Fri, 26 Oct 2018 13:48:34 +0000 (UTC) From: Nicolas Saenz Julienne To: stefan.wahren@i2se.com, eric@anholt.net, dave.stevenson@raspberrypi.org Cc: nsaenzjulienne@suse.de, linux-rpi-kernel@lists.infradead.org, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 08/18] staging: vchiq_core: remove unnecessary safety checks in vchiq_init_state Date: Fri, 26 Oct 2018 15:48:03 +0200 Message-Id: <20181026134813.7775-9-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181026134813.7775-1-nsaenzjulienne@suse.de> References: <20181026134813.7775-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org vchiq_init_state() checks the initial contents of slot_zero are correct. These are set in vchiq_init_slots(), using the same hard-coded defaults as the checks. Both functions are called sequentially and Video Core isn't yet aware of the slot's address. There is no way the contents of slot_zero changed in between functions, making the checks useless. Signed-off-by: Nicolas Saenz Julienne --- .../interface/vchiq_arm/vchiq_core.c | 59 ------------------- 1 file changed, 59 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 34a892011296..dee5ea7bfe4f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2170,65 +2170,6 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) return VCHIQ_ERROR; } - /* Check the input configuration */ - - if (slot_zero->magic != VCHIQ_MAGIC) { - vchiq_loud_error_header(); - vchiq_loud_error("Invalid VCHIQ magic value found."); - vchiq_loud_error("slot_zero=%pK: magic=%x (expected %x)", - slot_zero, slot_zero->magic, VCHIQ_MAGIC); - vchiq_loud_error_footer(); - return VCHIQ_ERROR; - } - - if (slot_zero->version < VCHIQ_VERSION_MIN) { - vchiq_loud_error_header(); - vchiq_loud_error("Incompatible VCHIQ versions found."); - vchiq_loud_error("slot_zero=%pK: VideoCore version=%d (minimum %d)", - slot_zero, slot_zero->version, VCHIQ_VERSION_MIN); - vchiq_loud_error("Restart with a newer VideoCore image."); - vchiq_loud_error_footer(); - return VCHIQ_ERROR; - } - - if (VCHIQ_VERSION < slot_zero->version_min) { - vchiq_loud_error_header(); - vchiq_loud_error("Incompatible VCHIQ versions found."); - vchiq_loud_error("slot_zero=%pK: version=%d (VideoCore minimum %d)", - slot_zero, VCHIQ_VERSION, slot_zero->version_min); - vchiq_loud_error("Restart with a newer kernel."); - vchiq_loud_error_footer(); - return VCHIQ_ERROR; - } - - if ((slot_zero->slot_zero_size != sizeof(VCHIQ_SLOT_ZERO_T)) || - (slot_zero->slot_size != VCHIQ_SLOT_SIZE) || - (slot_zero->max_slots != VCHIQ_MAX_SLOTS) || - (slot_zero->max_slots_per_side != VCHIQ_MAX_SLOTS_PER_SIDE)) { - vchiq_loud_error_header(); - if (slot_zero->slot_zero_size != sizeof(VCHIQ_SLOT_ZERO_T)) - vchiq_loud_error("slot_zero=%pK: slot_zero_size=%d (expected %d)", - slot_zero, slot_zero->slot_zero_size, - (int)sizeof(VCHIQ_SLOT_ZERO_T)); - if (slot_zero->slot_size != VCHIQ_SLOT_SIZE) - vchiq_loud_error("slot_zero=%pK: slot_size=%d (expected %d)", - slot_zero, slot_zero->slot_size, - VCHIQ_SLOT_SIZE); - if (slot_zero->max_slots != VCHIQ_MAX_SLOTS) - vchiq_loud_error("slot_zero=%pK: max_slots=%d (expected %d)", - slot_zero, slot_zero->max_slots, - VCHIQ_MAX_SLOTS); - if (slot_zero->max_slots_per_side != VCHIQ_MAX_SLOTS_PER_SIDE) - vchiq_loud_error("slot_zero=%pK: max_slots_per_side=%d (expected %d)", - slot_zero, slot_zero->max_slots_per_side, - VCHIQ_MAX_SLOTS_PER_SIDE); - vchiq_loud_error_footer(); - return VCHIQ_ERROR; - } - - if (VCHIQ_VERSION < slot_zero->version) - slot_zero->version = VCHIQ_VERSION; - local = &slot_zero->slave; remote = &slot_zero->master; -- 2.19.1