From patchwork Tue Feb 7 11:05:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13131388 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 1630FC6379F for ; Tue, 7 Feb 2023 11:05:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231917AbjBGLFt (ORCPT ); Tue, 7 Feb 2023 06:05:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231909AbjBGLFr (ORCPT ); Tue, 7 Feb 2023 06:05:47 -0500 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C1C9DBDC; Tue, 7 Feb 2023 03:05:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1675767946; x=1707303946; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xF4jDpA9qmX+Mr6H3ol1SyoP+RukmcdTgfZeN+x6MrE=; b=F1tsRY8x3EI3mP+aJLHj5Pvf1uhRrDNXwX217SRNzmBwns4h2Wxq94TU yl0EISBmbBtMSmaRmb03MFusbkl+hWN+f85wOnR0DHUDshx4/OxTGeO2u gfbhrAGwOlAaOTAvd/Q+0kyxXKDWUuftSHKCcdLkWwahX/ojzagS4hGy7 hOV0ARGDEmdirZqWaMJt4fKNkBEca85IkR8Tm+Qy7HV7KtU+ln61j8oV8 E5geszLcb2McNVfGWYTu4qfz2x4o6rOEYcK006CkRgWOa1vtwkVGOQj7M y9YS2jtBIEQcW1kdRgNW/URlWviRJYTjOkaDuBj64T4JJERjRSyixZ1SS Q==; X-IronPort-AV: E=Sophos;i="5.97,278,1669071600"; d="scan'208";a="28917152" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 07 Feb 2023 12:05:41 +0100 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Tue, 07 Feb 2023 12:05:41 +0100 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Tue, 07 Feb 2023 12:05:41 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1675767941; x=1707303941; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xF4jDpA9qmX+Mr6H3ol1SyoP+RukmcdTgfZeN+x6MrE=; b=bbQFVAauNtA8AcSz8nEsemS4XavL3lLNVVjyaOTy/kFvwRPlwU+NhL2/ k3jLhYq+9XbnbHqlZLpaIIBttvm7l1Kb3Heqi7/bKreB/hTw6YcVGmZAX 1rWuDRaZJVyNRak+5Mc+f1xjAGWQLTa1ZMY+BS4emO2Kj1IrlXDCHKwXT DONSdq56DkthPRZtQb2VB60aXjbq83Bwgb2di/9BamukXoDZVVPDY3xaV zR5yIHWuoQn+Wqi8Tnil70SAYZU8qpERMhetuzJePRfpI2PDngESWJF5d 55shciw0K12jk53nrkATRRCXxk5KGJ6ek2XKNz7KpMbC9bZMf5TBkgAUk A==; X-IronPort-AV: E=Sophos;i="5.97,278,1669071600"; d="scan'208";a="28917151" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 07 Feb 2023 12:05:41 +0100 Received: from steina-w.tq-net.de (unknown [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id ADC30280073; Tue, 7 Feb 2023 12:05:41 +0100 (CET) From: Alexander Stein To: Rob Herring , Frank Rowand , Greg Kroah-Hartman , Alan Stern , Darren Stevens Cc: Alexander Stein , devicetree@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 2/3] of: device: Do not ignore error code in of_device_uevent_modalias Date: Tue, 7 Feb 2023 12:05:30 +0100 Message-Id: <20230207110531.1060252-3-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207110531.1060252-1-alexander.stein@ew.tq-group.com> References: <20230207110531.1060252-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org of_device_get_modalias might return an error code, propagate that one. Otherwise the negative, signed integer is propagated to unsigned integer for the comparison resulting in a huge 'sl' size. Signed-off-by: Alexander Stein --- There is no problem if of_device_uevent_modalias uses the same checks as of_device_get_modalias, but this is error prone and cumbersome. drivers/of/device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/of/device.c b/drivers/of/device.c index 5b929351b65bf..955bfb3d1a834 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -385,6 +385,8 @@ int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env * sl = of_device_get_modalias(dev, &env->buf[env->buflen-1], sizeof(env->buf) - env->buflen); + if (sl < 0) + return sl; if (sl >= (sizeof(env->buf) - env->buflen)) return -ENOMEM; env->buflen += sl;