From patchwork Mon Oct 24 11:30:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp458819wru; Mon, 24 Oct 2022 06:38:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5N8Tk+7K7khGPlXMtTx/CxLQz4Rb8bWIz094Y2njSwybvzLagCpkeGUkSO947v8RPlIANI X-Received: by 2002:a17:906:cc58:b0:7a9:6b4e:79e4 with SMTP id mm24-20020a170906cc5800b007a96b4e79e4mr2986773ejb.57.1666618702448; Mon, 24 Oct 2022 06:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618702; cv=none; d=google.com; s=arc-20160816; b=GsMN7zmf/+MsuJuS5eEYWmivL7GIfpOh19TdbFCBkDPuNy61RkcCuv6Mu3tC6EM839 ufoSiyQ5n1idJZh/KKOyEVeU9lF+4XOooS6+uEhJOf+ux57Khjmx4O1AxlIW/T0+TXz6 mt43a+k5pEPJ7f1TpAV/iD4nHCVsMhPUp9a4Ot94aMyIkMaYx4t5faBZSr7H3wSxpQ3/ aIawY/iB0Egb/QEzb15dkrI+2qtbzHcl7A3hQhLkY4oqS5Ce+/+0Afdsz9e9jztggbHV uXxKy++3H4BP5t1Hi2g41w7l+o3Vj6XuRkALIJQ49Yjl2Q42jnqyFsqLH8KduMEBxJwT uuJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VEVpWNuIR22s2UJmOzjS4cN8lb/+ckr6ks3ZUQMp/Cg=; b=Ol6BZuqrhnGedPTyH7Kb3y4HX2FK5ML+6iVVA5BOVh+SISPhvNa+Z6mXBHyI5TKOYD DAIL4Jz+Sac61hT8hXp2ScYNkKzk+vyupnsUTNL2ASqYTObJoT5qmLnRCJkGOYqr8yXx 1u/KkqOIX2A4Eqqp9hhhWTZ1aP4J25M8eAjitNxpIy9/OCakV9VDk+0MYwH5mRZaD4n4 8t2q5iGYFpZ1myo9QTAJT/3iySprgKJ3JNojmnepXE4Rr10ksQeDBSwuw40cUcQkStDF 3RaZKrP+/KVWo9mO6VRQ3U8YFTjcYyQYuB527lHbz3M24baaN7Dhje+KGYyG6obyoo0H aD2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UMuGKLUK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc33-20020a17090716a100b007a11c253eaasi7211499ejc.809.2022.10.24.06.37.35; Mon, 24 Oct 2022 06:38:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UMuGKLUK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231956AbiJXNXd (ORCPT + 99 others); Mon, 24 Oct 2022 09:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232553AbiJXNWn (ORCPT ); Mon, 24 Oct 2022 09:22:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B26B13F8F; Mon, 24 Oct 2022 05:29:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AD252612BC; Mon, 24 Oct 2022 12:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD599C433D7; Mon, 24 Oct 2022 12:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614400; bh=1QUJDNqcFFRSgqgvnf6wISDMsBWhPp8lS7GZcNtc4uo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UMuGKLUKnbLZzC1Hyp84e4OHB1hSz82Ddr22JgCqKvDziyLQum27tJqWg7QJxzGcD 96tn4Rb9YrPyF3JfV4R3pRIWuQkR6YE5ol/szqzckmaMKY0T8KqOruAfAyePY0zU0y lPzsg1mWRYt3ShZo/Kg5B25g2pihtCC3Dy64XLmM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Eddie James , Joel Stanley , Sasha Levin Subject: [PATCH 5.10 246/390] fsi: core: Check error number after calling ida_simple_get Date: Mon, 24 Oct 2022 13:30:43 +0200 Message-Id: <20221024113033.316461841@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747576372879179576?= X-GMAIL-MSGID: =?utf-8?q?1747576372879179576?= From: Jiasheng Jiang [ Upstream commit 35af9fb49bc5c6d61ef70b501c3a56fe161cce3e ] If allocation fails, the ida_simple_get() will return error number. So master->idx could be error number and be used in dev_set_name(). Therefore, it should be better to check it and return error if fails, like the ida_simple_get() in __fsi_get_new_minor(). Fixes: 09aecfab93b8 ("drivers/fsi: Add fsi master definition") Signed-off-by: Jiasheng Jiang Reviewed-by: Eddie James Link: https://lore.kernel.org/r/20220111073411.614138-1-jiasheng@iscas.ac.cn Signed-off-by: Joel Stanley Signed-off-by: Sasha Levin --- drivers/fsi/fsi-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 59ddc9fd5bca..92e6eebd1851 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1309,6 +1309,9 @@ int fsi_master_register(struct fsi_master *master) mutex_init(&master->scan_lock); master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL); + if (master->idx < 0) + return master->idx; + dev_set_name(&master->dev, "fsi%d", master->idx); master->dev.class = &fsi_master_class;