Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3795065ybi; Mon, 29 Jul 2019 12:46:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcard3iqNPhXqoL3KuGYSP/I6OeIQlHTSSxmDzPDuWt2sc9X3PzrGgYttqGFB/MAn2LMMS X-Received: by 2002:a65:690e:: with SMTP id s14mr92884755pgq.47.1564429586595; Mon, 29 Jul 2019 12:46:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429586; cv=none; d=google.com; s=arc-20160816; b=Zm+MkXg27tFYGB87PGZW1Iv56cVRWh3xFD/6YHn116/Vo2sHH56H4vuImJzm00txNx 2D6gZA+RqGU0bLHn96X8cW2eNeJwvbA7TSzW6wYmRgWFB5TQmpRDyooDsWzxantsjRJ1 hrmPMEtSQ9G1yoW2M6d9v9MS+KjlzjZ09D54TcPVjRLcku6mXKlGf0AwcoFCmg5Jmdri FN8G4NI+n5NNZsWH5ZmgOqvoSEnYu+X67mUd8G+9d0SRuBwDIfng0JBdjJMBzqG8KA3a y67J/W9PglG3MqBBvUveWDJYfWW2KOGd8AHK8D+MScC7JVwxFNKGV43pMxJ+P/FlceOI 3+Sw== 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=NQGb07sJp0K1j+6iIJ39XbX4BYacbL4UuJlYEJISgs8=; b=kEe4AUvtnK973FtcpALnw81Mrv9ZoWnJKY9HCiZlN7acsXBoQtBTa9+CqQvMg9g4GW cB/OAe+67T9gPnnyfx3LPhrmForJ03a0Qkw5Bd9rQ/n7ajjdnkMLVL8bgTBb/DPnISIH TWdRuVQNwcfT4nVsUYUX7ehGOVRDvYTXRVeiVZnw8dHyLFDAwa93HUbjw63OJTk1eCzk 1Xboy2Lhw5s36UVzVG38y0XzDnsROgmnp2iwdeeGU9+q9oPvykNFLHht3FAvUE3Vn8wA qNnUV7PB1RKBsbZuYU9U5OY5IClQ3LgY2hjnAYPs2AWUUkWeOBlzRVA8k9Dn17qXQTPr qtWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RBj3hhte; 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 t189si30023386pgt.428.2019.07.29.12.46.11; Mon, 29 Jul 2019 12:46:26 -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=RBj3hhte; 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 S2389894AbfG2TpE (ORCPT + 99 others); Mon, 29 Jul 2019 15:45:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:33660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389851AbfG2To7 (ORCPT ); Mon, 29 Jul 2019 15:44:59 -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 5A69720C01; Mon, 29 Jul 2019 19:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429498; bh=oMVB5LUCxLBc4d04rJgABbGj+3wyZ+J3zsf37SFGpH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RBj3hhteEjANR893qEXecaxw23ofKrgbtBpzQcSdK9OSff54fP8CjAoPqGvA2ifcq lRX/OX2LKCOm1uHUQtoyn3AtzC03AXOb7RccPIZeWRpzu5vjadPNnxzOl07m7hYp+M EaZrROWpvmrRn8B33QAT/22mu0pYRz376ox0J6cY= 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 4.19 078/113] mailbox: handle failed named mailbox channel request Date: Mon, 29 Jul 2019 21:22:45 +0200 Message-Id: <20190729190714.296045350@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@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 674b35f402f5..055c90b8253c 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -391,11 +391,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