From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69D56C76186 for ; Mon, 29 Jul 2019 19:45:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 37D6B20C01 for ; Mon, 29 Jul 2019 19:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429506; bh=oMVB5LUCxLBc4d04rJgABbGj+3wyZ+J3zsf37SFGpH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=I5NqA1w05xfZcCzVI4Imvl55x0p8g1QeB6d6snCaaj227KdiptmvfqyeIfz4P5VOg aSM5vUmcurpyI0StOac5IaDkKO5HfKQyeQbsL3fMKE87/ib2u9ByiU2njjg+KvyMDM qKZtbIw2m80vQxq8vu/6zgmvkBtaRkbNPUXpSs9U= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389897AbfG2TpF (ORCPT ); Mon, 29 Jul 2019 15:45:05 -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