Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3801746ybi; Mon, 29 Jul 2019 12:55:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8fEkCVWTrrvvGA7fokJk24SCw0CT7k71ROPHRxNTOl9/16quUZ4JQgDnnC1kGOt1xw5JB X-Received: by 2002:a17:90a:1904:: with SMTP id 4mr116736165pjg.116.1564430105772; Mon, 29 Jul 2019 12:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430105; cv=none; d=google.com; s=arc-20160816; b=hgyZ4v8YNNFq7AfB5SHQmvpYjTANyuaNcZ8C9MwNEqk9ffq7cZ7ANagI4V9djDt0mh a12D0e6uHszZBzUcJbmsrPA63jeD1bhYpE8YGwoY24M9k3aISPYx5ucE0ZH6d53ruSy0 ikQyCtnpjoUGA5l1t4EfYyJNJm/V+gV4S1rbdWyBqT9DlG8kGHYy3xsv7sqprcZvdIOG CZuW5aAoicU641kuvbEB8Iuk77N1DbbqqwyJc14sI66K37KlvbwkrjtouqKtTLyMizNH DiM0sWbkUKilJZuScdQtlrHJgFkCMj8mmXOI4MrQsNtbo0FLY3caJRN1ZdDKRhlijlU2 6uKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d59lAm6C4yESA2oLOSbGQMwR9CFls7WYLUHSsdG7v+Q=; b=Py0tlpON1ito2NWlS/vIh3ieUsA/lJqZ+HNwuDivmel/Ks2INlWImbL2fqaFjZ7LBY ygjRu6JMvN7FPD+LKQnPRczh4/3+wD5Vhujt1frzKDOcTNZETxUszmCoMz5xjvqCeV3l LWPOsKXSXi63IO9rpCXJxHriQ0qoZiAwTAPONDbdbrYKqSnX50mFXNpuUCuMJKvQniOf y/DzTU6ObBeTTb7G/tp5OTgqokICDKQDMIMRCA9Dtb5BTkNaIVbnyt6Ixpq2JbRTFBOM tpA5/BN4wn0KXaZ9cIRZTbFaHkBg7Nl+nPRhe4Mzu/JCVFjCDIm+2dKEWQ9/bdIJhNxA 4g3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mDq3ggJk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j100si24494737pje.52.2019.07.29.12.54.50; Mon, 29 Jul 2019 12:55:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mDq3ggJk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390486AbfG2TwU (ORCPT + 99 others); Mon, 29 Jul 2019 15:52:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:44036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390868AbfG2TwQ (ORCPT ); Mon, 29 Jul 2019 15:52:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 22E782171F; Mon, 29 Jul 2019 19:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429935; bh=CTuAuaTLazECyivSnK5XnsZFPeOlr9DkR+6xrHXFSGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mDq3ggJkkaLX1cdNh9MCiDLwZYO1l/abCYpYqU+vaN7VlUidbZ/fASjHeq89601aN wqIOcpQM9XfjeSBPAefFaThCAaxYWGW+y7W0W6uCKmObzLyANllvmCaLdprss6dC8l pgwe/lffnC5ykSL4ahSXGJRtXcH4jBk+uTbZSiLA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Morten Borup Petersen , Jassi Brar , Sasha Levin Subject: [PATCH 5.2 143/215] mailbox: handle failed named mailbox channel request Date: Mon, 29 Jul 2019 21:22:19 +0200 Message-Id: <20190729190804.444390948@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 25777e5784a7b417967460d4fcf9660d05a0c320 ] Previously, if mbox_request_channel_byname was used with a name which did not exist in the "mbox-names" property of a mailbox client, the mailbox corresponding to the last entry in the "mbox-names" list would be incorrectly selected. With this patch, -EINVAL is returned if the named mailbox is not found. Signed-off-by: Morten Borup Petersen Signed-off-by: Jassi Brar Signed-off-by: Sasha Levin --- drivers/mailbox/mailbox.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index f4b1950d35f3..0b821a5b2db8 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -418,11 +418,13 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, of_property_for_each_string(np, "mbox-names", prop, mbox_name) { if (!strncmp(name, mbox_name, strlen(name))) - break; + return mbox_request_channel(cl, index); index++; } - return mbox_request_channel(cl, index); + dev_err(cl->dev, "%s() could not locate channel named \"%s\"\n", + __func__, name); + return ERR_PTR(-EINVAL); } EXPORT_SYMBOL_GPL(mbox_request_channel_byname); -- 2.20.1