From patchwork Sat Oct 22 07:25:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7633 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1107551wrr; Sat, 22 Oct 2022 01:41:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Q2KrGQ5oR4vAdpYiVx1mN0CzzHKczqR1WYD/GsQvehDXD5eybyQ5vu02/QpohJgBXF7nd X-Received: by 2002:a17:907:2e19:b0:78e:11cc:3bc5 with SMTP id ig25-20020a1709072e1900b0078e11cc3bc5mr19259856ejc.543.1666428074836; Sat, 22 Oct 2022 01:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428074; cv=none; d=google.com; s=arc-20160816; b=F7uzoHve44ILTyvEraiRKfG9l/bBm7kfnxPIySpFDy7h1PuinnBxS8+MTjvqTi3mJU s3DLn17bv2vTJwy5qSYGG6wNVH1xE5rRPyOXlfvXTe3kEprCSlR7gHeBzbubXDfeYlhP 4eBuHCm6Bx3hG56w9/yMP6V+8LuyzMgzYgo+UaFKHItDi2qMg68C+YKxywuNa3f/vy4b atOjg8DHWsYbvKKWBfbPlMrtSvjKjwjG38/fE6U+iUTvr5pwt/ENA64jb6GwRgpnXd0a EJ6+xtboSASSFyrpfn80R7S1DHSdVJxTTEXssC4EFlwgTrsaBWlwJnufTEfMMkQjFo4m BXkw== 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=2gns+FEdS4MRDGVMHTHPbHNp/HxSEF7fIZwKgvc6t3o=; b=jik/nOUN/bT0JQv2VScz/bEcrcgWNKAUzNnMRyoiD56d2vYWVCiftTuTQoF3vnW9eY nszfgZCqDIxuJlDT8ehui0hgZB/ib3T3irWb7Y+c07Zk6w1m7PbJFiRj+yv3Vl9vAPrp +nAHSdMcbYornuXTbJZpuV/mwmUSXNJ9r+mZM7+eh1wCHV7nnSHflnYE7CoxiAquDiY0 lLs1+WcWp6gdQ5ZErXGZvJ0bgut2WMdERrca36Syo4P7xJngpmmknDem+Arbo2CkYB5+ fDeDoH9r1prNNufCnSUuxN2GffdUXPbjzm0qcUqtnJXnBLl+sQccV0N2065hEFIEtPpV QPaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="t3oemX1/"; 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 dp19-20020a170906c15300b0078c47b4478esi20810162ejc.106.2022.10.22.01.40.46; Sat, 22 Oct 2022 01:41:14 -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="t3oemX1/"; 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 S234477AbiJVIi3 (ORCPT + 99 others); Sat, 22 Oct 2022 04:38:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234108AbiJVIdu (ORCPT ); Sat, 22 Oct 2022 04:33:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C8592E7150; Sat, 22 Oct 2022 01:03:47 -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 39EBF60B80; Sat, 22 Oct 2022 07:55:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 467E0C433D6; Sat, 22 Oct 2022 07:55:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425326; bh=1OAwvSabGh6LnKItuicwtRw9I08Q/Qc3Yz5P8kejiIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t3oemX1/VzxFe+9RlpVQFHXG4pKlCxr6XFYZ37lOUDf1gy2hcmuJxxYb46RP9uhcD ylaIqYQu/ELXvh/e8XGweFXJnN/0jF4VHMo89A1SX0PdbOuV2gwvs7qo7BMOcsSO8u zZX7Vii/Vd8hIlQ2nRkaECAS3F6quhUOstmE7ses= 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.19 465/717] fsi: core: Check error number after calling ida_simple_get Date: Sat, 22 Oct 2022 09:25:44 +0200 Message-Id: <20221022072518.876493488@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747376484705099857?= X-GMAIL-MSGID: =?utf-8?q?1747376484705099857?= 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 3a7b78e36701..5858e6339a10 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1314,6 +1314,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;