From patchwork Sun Sep 3 12:46:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 9936295 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 53DAB6037D for ; Sun, 3 Sep 2017 12:46:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44BF32864B for ; Sun, 3 Sep 2017 12:46:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39270286B0; Sun, 3 Sep 2017 12:46:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F08A32864B for ; Sun, 3 Sep 2017 12:46:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751766AbdICMqQ (ORCPT ); Sun, 3 Sep 2017 08:46:16 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:40868 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751604AbdICMqQ (ORCPT ); Sun, 3 Sep 2017 08:46:16 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1doUI2-0004cb-Ik; Sun, 03 Sep 2017 12:46:14 +0000 From: Colin King To: Ohad Ben-Cohen , Bjorn Andersson , linux-remoteproc@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][rpmsg-next] rpmsg: glink: fix null pointer dereference on a null intent Date: Sun, 3 Sep 2017 13:46:14 +0100 Message-Id: <20170903124614.6248-1-colin.king@canonical.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King In the case where glink->intentless is true and the call to qcom_glink_tx fails then we have a condition where ret is non-zero and intent is null, causing a null pointer deference when setting intent->in_use to false. Add an extra check to only dereference intent if intent is non-null. Detected by: CoverityScan CID#1455247 ("Explicit null dereferenced") Fixes: 88c6060f5a7f ("rpmsg: glink: Handle remote rx done command") Signed-off-by: Colin Ian King --- drivers/rpmsg/qcom_glink_native.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 666068202597..8bc0d0456a40 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -1264,7 +1264,7 @@ static int __qcom_glink_send(struct glink_channel *channel, ret = qcom_glink_tx(glink, &req, sizeof(req), data, len, wait); /* Mark intent available if we failed */ - if (ret) + if (ret && intent) intent->in_use = false; return ret;