From patchwork Wed Jul 15 20:22:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 1329809 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B6TN72PTnz9sSd for ; Thu, 16 Jul 2020 06:23:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6EF5681B6E; Wed, 15 Jul 2020 22:22:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 8625081B7D; Wed, 15 Jul 2020 22:22:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1416C81B65 for ; Wed, 15 Jul 2020 22:22:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=thomas.petazzoni@bootlin.com X-Originating-IP: 90.30.52.66 Received: from localhost (lfbn-bay-1-589-66.w90-30.abo.wanadoo.fr [90.30.52.66]) (Authenticated sender: thomas.petazzoni@bootlin.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id EF53840002; Wed, 15 Jul 2020 20:22:50 +0000 (UTC) From: Thomas Petazzoni To: Joao Marcos Costa Cc: u-boot@lists.denx.de, miquel.raynal@bootlin.com, Thomas Petazzoni Subject: [PATCH] fs/squashfs/sqfs.c: use sqfs_read_sblk() in sqfs_probe() Date: Wed, 15 Jul 2020 22:22:44 +0200 Message-Id: <20200715202244.2169913-1-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200709175148.17193-1-joaomarcos.costa@bootlin.com> References: <20200709175148.17193-1-joaomarcos.costa@bootlin.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean sqfs_probe() currently duplicates what sqfs_read_sblk() is doing, so use the latter in the former to avoid some small code duplication. Signed-off-by: Thomas Petazzoni --- fs/squashfs/sqfs.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c index 27f0b33a92..cd3fbade7e 100644 --- a/fs/squashfs/sqfs.c +++ b/fs/squashfs/sqfs.c @@ -1017,20 +1017,14 @@ int sqfs_readdir(struct fs_dir_stream *fs_dirs, struct fs_dirent **dentp) int sqfs_probe(struct blk_desc *fs_dev_desc, struct disk_partition *fs_partition) { struct squashfs_super_block *sblk; + int ret; cur_dev = fs_dev_desc; cur_part_info = *fs_partition; - sblk = malloc_cache_aligned(cur_dev->blksz); - if (!sblk) - return -ENOMEM; - - /* Read SquashFS super block */ - if (sqfs_disk_read(0, 1, sblk) != 1) { - free(sblk); - cur_dev = NULL; - return -EINVAL; - } + ret = sqfs_read_sblk(&sblk); + if (ret) + return ret; /* Make sure it has a valid SquashFS magic number*/ if (sblk->s_magic != SQFS_MAGIC_NUMBER) {