From patchwork Mon Oct 24 11:31:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9917 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp584276wru; Mon, 24 Oct 2022 11:06:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5wHvRRgl4fJKRPNqp94Izt8mllZMzxrLi12gkUraktsFDQXYURrgHSeNo6DDjfuG4Llv3E X-Received: by 2002:a05:6a00:32cb:b0:563:2d3b:5c8d with SMTP id cl11-20020a056a0032cb00b005632d3b5c8dmr35472242pfb.85.1666634759999; Mon, 24 Oct 2022 11:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666634759; cv=none; d=google.com; s=arc-20160816; b=MZgyqIHA9pfMQkBxbfd8CAWhkVOdr5+0qiybzZRKyLv6PDequw96LiPVyGxM4nOHVC XMHxBufKQBbtFc+TLae7PxeOSmYb/Rfivc21AqNe1yfixo9lMvVO6io22BEV3PTr15eh KcgGNYAl7sFsDz4tQ8luzWv3RRxK6FSFzDb5lw1NpEx2UlAy3G7VPDlfS6WOq+dfKA5t v4s1GMiY7prxNsZtEaLuFhY6b2P1i/JUb0Cg7Lkwkor27V5G/lQru6g7dU/s/7RAPK0d 6KafqcRzIEzpUDEohy9X/I89jy4S35lYKpK6DGzxWNJKOCtKfZIDIFo7IMKk8YGzEXQo DpZg== 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=MVLaClsOCJlAJxnM5R6HQIZPB2eSw98HDUjUorAtjxF2B4/IZmELJjZbDHYANAxdEh cMA0OgrcYCc+X5s6Zelh9CN4D4iQMOmN6BsqNHJ5UNY5ECG/0Ifh/1/kIDcFk5fjOVQ1 uG09eAOfXAT6ubOqhO8z5IJRQqMlug8QhqUACERzMlbCCfCoKnlaqcVcej6zHZ3Zzyae g96/kXFTEOLfLTP3AAgk/BoJBO3m7XQGk1RMLZ7IMWKRig3P9ALQflOwr38I7yPbatZx oDDZ7XJfDQMRux7UVx0Zn/flqWCAQXtcF7ljcL0psSF/9svfBXSiwy1QDUaeX0HxuADx rV4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uonYJPtE; 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 u13-20020a170902e80d00b0017f57787a5dsi217459plg.223.2022.10.24.11.05.47; Mon, 24 Oct 2022 11:05:59 -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=uonYJPtE; 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 S230243AbiJXR5u (ORCPT + 99 others); Mon, 24 Oct 2022 13:57:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbiJXR52 (ORCPT ); Mon, 24 Oct 2022 13:57:28 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 408576F553; Mon, 24 Oct 2022 09:37:25 -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 sin.source.kernel.org (Postfix) with ESMTPS id A9F8DCE16D5; Mon, 24 Oct 2022 12:47:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 959D5C433C1; Mon, 24 Oct 2022 12:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615670; bh=1QUJDNqcFFRSgqgvnf6wISDMsBWhPp8lS7GZcNtc4uo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uonYJPtE0iWAqTbVgJ0ZFuoa4mSCRgXiXVh9eogmShSz8EXbR40su9pehwpGPO4au snhchSONXKnN/sHjWtNrX22rCEJVM4FB4eqhO4ryppGyPosGjTZ4GDa23u3pbUWXQH oHKBVR29PgibWLAf/IHxw4x8uQS0jLXb6kI5i2Pw= 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.15 340/530] fsi: core: Check error number after calling ida_simple_get Date: Mon, 24 Oct 2022 13:31:24 +0200 Message-Id: <20221024113100.391210510@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747593209986138493?= X-GMAIL-MSGID: =?utf-8?q?1747593209986138493?= 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;