From patchwork Mon Sep 15 12:28:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 318 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939380; bh=G5hXVb3iyaEzOO2Hq5YmEDBbvraYRXP8S1ZYTePfwGs=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WqnTqcoYZf+w/MZHGID1bFa1Ll7foU4H7FdWNWmlzvR+vFLbfDcDxzaki2rAFKHnP rhHzKFi/xiEyZJ28+F9l+zJdErGOAvAU4/y/D23DleptHQ73hY0YLkTqv0e8gBiDZo nH0zvPJZH6Ff//73f97DecAP+qg7Wa05NysSSO5gcIEp9OHFB4Z3ziAy3Zorwbab/y /8JqvmbzfYCM+sXU7m33BTSWYTPdNmk+DPEABIRGiPl3qxuUmoTVyNCtflrx1soSvQ HQlwdFQ6IRbXy79ltis9o0xh4ynPQ+KC50/05D43me9C43fNrqfzWkE1oDrOBrjvm1 hZ/cqwl6Guo3A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A0C2867B3C for ; Mon, 15 Sep 2025 06:29:40 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 6_NvBvqtKEqD for ; Mon, 15 Sep 2025 06:29:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939379; bh=G5hXVb3iyaEzOO2Hq5YmEDBbvraYRXP8S1ZYTePfwGs=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=pve6Lp2ZugAeFKguRwDgUANajt+fXlGMIT/WHFfxAIGnsuKOcEoJ9RXrkYuy4ZWDx OnPSIOjTmYQ6Jlz0OhZjyITyYs0jB/ht7z6msIePVvXfcC1Gpz5VGSMx5c2l/nN6cp dytzyJUcbxr5/m0cPSQXRNrf702dRanVw0D7ylDeh/4+bvMWt6fjx9whAdzW+GtAei tFixjS/Mqb7bF5I/8sPIbywFYkni4UCkN+2y0xdQbb9yGXuVa5dTiAfx8c7OHJrRk5 1uGL1XAgegNJRDrWTct2ogzeKWk+ClFbS1Sr8+GzjBcdnclYnqxt2CL8NlcN0+R9Ao JlbkvDuxdyoyw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EA0FD67BCE for ; Mon, 15 Sep 2025 06:29:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939377; bh=wms5hR+7XJhOkBI6wUPGaw+thMemONdeZuMM7HRJNAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v2QGEgMXImD93GzKHHzMKJ9GqA1skJfctpvlXcsbt7+4ELySAnRoKVKvFA1yhz//0 X8TJzGblxjwWtzLt3CKKThFDpakvIJxAncEU87PimYBY/6/W5Zgdef3Flz3X5UdmRw IPPgLUxc26xdeOZzyiRuuDqJ7sKe4OT69cQMAxFkvoRSAREXzVc+mo+jHP3IZSY4Yt tez0kHAirztBThijHGXvljH35h8knhHCJywdrIeE7haRAPq2zs7/BzGIXY9l6A0JDy PN/xP9K4R+3QsVzIK+jfPP5ovOnUQv/kBX/8PSaETi8A/6ojNzkN/RkA55/MXA5r6s enWeyTVSdJ+vw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5FB2267B45; Mon, 15 Sep 2025 06:29:37 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id wfXmolPZqAr6; Mon, 15 Sep 2025 06:29:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939375; bh=RuoBCAkUifMi64jUfb9yTHZPPKNQHGkOiiUWfOrntFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gZQqkg2R51WOMajlqbBI9yar4eJEyir2AI2z7kOErTRzf+fL5rNyLScpuwCgwvE4h UFDDpZoc2iZ/ZoP/lXcXHx7yL3y1oW3IH9658Amemq+P6uH+Hdx8MqevGEHVuvYnDi dWUg+6Lq+V/KIfhX3JFkNpiAZNhxKh7pjDIqX6wk9PsBIVpVtvlZ+SGr1zMqi988q8 rRWyzKVovXn0P4C26YZwRLZXea6WobBz17rabeqLu4IikMTC/9zz5U3G5qb1XOkX+3 MZWh/Ea49vcDg4nH+dHP3+5/IgAtXziXRN+oKrMlauTqq43OvLYE9SXksHX099yI8z OSWCXx7Lm0uNQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9A61D67B3C; Mon, 15 Sep 2025 06:29:35 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 06:28:36 -0600 Message-ID: <20250915122905.1217249-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915122905.1217249-1-sjg@u-boot.org> References: <20250915122905.1217249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QPQQ2PGICGPQMY5DWDLC5VC35RPM2OFL X-Message-ID-Hash: QPQQ2PGICGPQMY5DWDLC5VC35RPM2OFL X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/23] expo: Guard against a crash in scene_textline_calc_dims() List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass If there is no console (e.g. in a test) this function segfaults. Add the console as a parameter so it is clear that it is needed. Check for it in the caller. Signed-off-by: Simon Glass --- boot/scene.c | 6 +++++- boot/scene_internal.h | 5 ++++- boot/scene_textline.c | 7 ++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 564037b0e1a..493f2bbab97 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -1114,7 +1114,11 @@ int scene_calc_dims(struct scene *scn) struct scene_obj_textline *tline; tline = (struct scene_obj_textline *)obj; - ret = scene_textline_calc_dims(tline); + if (!scn->expo->cons) + continue; + + ret = scene_textline_calc_dims(tline, + scn->expo->cons); if (ret) return log_msg_ret("men", ret); diff --git a/boot/scene_internal.h b/boot/scene_internal.h index ba05e05d99a..eada390275c 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -21,6 +21,7 @@ struct scene_obj_menu; struct scene_obj_textline; struct scene_obj_txtedit; struct scene_txt_generic; +struct udevice; struct vidconsole_bbox; enum scene_obj_t; @@ -380,9 +381,11 @@ int scene_dims_union(struct scene *scn, uint id, struct scene_obj_dims *dims); * Updates the width and height of the textline based on its contents * * @tline: Textline to update + * @cons: UCLASS_VIDEO_CONSOLE device (cannot be NULL) * Returns 0 if OK, -ENOTSUPP if there is no graphical console */ -int scene_textline_calc_dims(struct scene_obj_textline *tline); +int scene_textline_calc_dims(struct scene_obj_textline *tline, + struct udevice *cons); /** * scene_menu_calc_bbox() - Calculate bounding boxes for the menu diff --git a/boot/scene_textline.c b/boot/scene_textline.c index acaf3d91bbc..4a77cc652a8 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -60,7 +60,8 @@ void scene_textline_calc_bbox(struct scene_obj_textline *tline, edit_bbox); } -int scene_textline_calc_dims(struct scene_obj_textline *tline) +int scene_textline_calc_dims(struct scene_obj_textline *tline, + struct udevice *cons) { struct scene *scn = tline->obj.scene; struct vidconsole_bbox bbox; @@ -71,8 +72,8 @@ int scene_textline_calc_dims(struct scene_obj_textline *tline) if (!txt) return log_msg_ret("dim", -ENOENT); - ret = vidconsole_nominal(scn->expo->cons, txt->gen.font_name, - txt->gen.font_size, tline->max_chars, &bbox); + ret = vidconsole_nominal(cons, txt->gen.font_name, txt->gen.font_size, + tline->max_chars, &bbox); if (ret) return log_msg_ret("nom", ret);