From patchwork Thu Oct 20 23:24:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Fedorenko X-Patchwork-Id: 13014146 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA861C4332F for ; Thu, 20 Oct 2022 23:25:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229766AbiJTXZd (ORCPT ); Thu, 20 Oct 2022 19:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbiJTXZ0 (ORCPT ); Thu, 20 Oct 2022 19:25:26 -0400 Received: from novek.ru (unknown [213.148.174.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0E8892CF8 for ; Thu, 20 Oct 2022 16:25:19 -0700 (PDT) Received: from nat1.ooonet.ru (gw.zelenaya.net [91.207.137.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by novek.ru (Postfix) with ESMTPSA id 6DB65504EEE; Fri, 21 Oct 2022 02:21:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 novek.ru 6DB65504EEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=novek.ru; s=mail; t=1666308070; bh=gSJc2hVPi+/cC5gO4Oe8MO5CLa+NDkKvF6zEYImcZXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hi+qjyWFOe5zJ+Wjk0q6UAQs01IEBOAYjC+rML1nvYIOcJ2vKdnwCitP7+/nZqXP3 xyK0P4vwTrXEXMQQDGGKFF04fMjl4I2uwY9tLJ6oCeQSjJe0i7UllJf1k4JSOXqNoh PtaUsIjYFfTvZUtXu2l7P5dvVQGUM61Ryi0acsKI= From: Vadim Fedorenko To: Richard Cochran , Jonathan Lemon , Jakub Kicinski Cc: netdev@vger.kernel.org, Vadim Fedorenko Subject: [PATCH net-next v6 5/5] ptp: ocp: remove flash image header check fallback Date: Fri, 21 Oct 2022 02:24:33 +0300 Message-Id: <20221020232433.9593-6-vfedorenko@novek.ru> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221020232433.9593-1-vfedorenko@novek.ru> References: <20221020232433.9593-1-vfedorenko@novek.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vadim Fedorenko Previously there was a fallback mode to flash firmware image without proper header. But now we have different supported vendors and flashing wrong image could destroy the hardware. Remove fallback mode and force header check. Both vendors have published firmware images with headers. Acked-by: Jonathan Lemon Signed-off-by: Vadim Fedorenko --- drivers/ptp/ptp_ocp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index d2d486ccd714..154d58cbd9ce 100644 --- a/drivers/ptp/ptp_ocp.c +++ b/drivers/ptp/ptp_ocp.c @@ -1530,11 +1530,9 @@ ptp_ocp_devlink_fw_image(struct devlink *devlink, const struct firmware *fw, hdr = (const struct ptp_ocp_firmware_header *)fw->data; if (memcmp(hdr->magic, OCP_FIRMWARE_MAGIC_HEADER, 4)) { devlink_flash_update_status_notify(devlink, - "No firmware header found, flashing raw image", + "No firmware header found, cancel firmware upgrade", NULL, 0, 0); - offset = 0; - length = fw->size; - goto out; + return -EINVAL; } if (be16_to_cpu(hdr->pci_vendor_id) != bp->pdev->vendor || @@ -1562,7 +1560,6 @@ ptp_ocp_devlink_fw_image(struct devlink *devlink, const struct firmware *fw, return -EINVAL; } -out: *data = &fw->data[offset]; *size = length;