Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3101055ybi; Thu, 18 Jul 2019 21:03:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyRbpYwJSWX7wqejy+ChREmxi5PhF1ApjbnxSlD56EzED8xM3Xzjyvxi+5M5+SA0MmQoQ8 X-Received: by 2002:a17:902:f095:: with SMTP id go21mr55344310plb.58.1563508993851; Thu, 18 Jul 2019 21:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508993; cv=none; d=google.com; s=arc-20160816; b=yStR9g05eD6WMtfuCjqXZxZgMaPCe8+Xep8JTZ39w9a40X2eib5N4ftZp2faxlkJ4K Kmy9J2zaBX1Zow4XPkDxVjO0ppwSh/zBPaLn6khrGzmOkEwgcEPXUib2k9r9nKfyby+M fQgR9QQtUsJD8MhmCTARoBZahI0dLQl04u4SMmXXBWZR396S/6xdklh96ac6sbddQ+zw 2Ls+PGpS675kXBrYnq2Mo1JvOSamRGxDxBmtFNml0/HJSrtfsxS9Yx4MbzXSdQ/3WStb yFNSU/orHThFn7nIk3NPyfeeElX2xD5lXOF5b/iUQ5gZZ5wHFhZUqhggaoG4E1x9ayE/ VDJA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M2JGh5xHGz0VKc3Kxz+nBaMx1TtHjeujC8APRqTOVSg=; b=oxBCNirCsgmCwXb8nqWOXiozJoNx+fsIpCaAzUwTj/GNlmtQNMaHb8hzn+O5o9time 7NZKv7GCPDUjaW+kEXhbQ/U1mEkUX3YiWTpmtPt6m++xu1zmmRnnNoVK7cTnRIK1S2wF t0sAwhHPy6fFQUyNApmKeSsLr7LhWWRD2BVM9BygTd117CIGuFg+dAovQa/qJlridRdV imbPe9qfYXPt1nPBZeNKCkdiWaykLqC/TX90zKaYvirJPZ+5hGGPtwv0Gq/TN/Enj461 Qp1WwOtTJlBQ5137l+CJne34E2oF23nx29eBzQRARcnK1s/pdNAe+bnMk0imClVYrzN2 3huw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CLfTMYSL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si829454pjs.86.2019.07.18.21.02.58; Thu, 18 Jul 2019 21:03:13 -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=CLfTMYSL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729722AbfGSEBz (ORCPT + 99 others); Fri, 19 Jul 2019 00:01:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:33374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729582AbfGSEBj (ORCPT ); Fri, 19 Jul 2019 00:01:39 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D221E21851; Fri, 19 Jul 2019 04:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508898; bh=U8pxwKUR8lFaTq3mQqf/ccRDfesiLsyvkbKgW/aXvvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CLfTMYSLi77PG62l0eYCLVMcLdul5ae2O0bXOQiEUgqlgHfJdJnl4zRr8CMQq59IE zVVCm3t8lJbvdCoXFJcH487kqXl/bC35wkiW30l2I+tgE6qMzwH+PQy/VOBgVPmohM A3jiOTsirAP5/csZUkWQkkyGHJHXvio9yLtWHdbU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: morten petersen , Jassi Brar , Sasha Levin Subject: [PATCH AUTOSEL 5.2 146/171] mailbox: handle failed named mailbox channel request Date: Thu, 18 Jul 2019 23:56:17 -0400 Message-Id: <20190719035643.14300-146-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: morten petersen [ 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