Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2660213imm; Fri, 24 Aug 2018 03:10:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaXZbYIor4tonLfUXzWh6tm0N2/tQ8oSNFdRx1RpaP3g/o6xqoGf/v9pmkw1iFbJibfi0/n X-Received: by 2002:a63:1d64:: with SMTP id d36-v6mr1042193pgm.92.1535105420705; Fri, 24 Aug 2018 03:10:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535105420; cv=none; d=google.com; s=arc-20160816; b=JMXKYGRUnMRVSZT/1l03aApQAcF8y79YafcLEPHk4V+aj0rC08DKK1JXvf4pyutIoM gY17S1Pw2J1GQxlCUCUeYI5timxMA5kOwTmuJWUK4yRtKVzUa8SQGDJLsap2vSmYX1nF /lBmjzIz9XAjkQtFYv48DDpXGA8iP2oYc4e6RD79qzruISxP/7rrGaLUnHC9YW70S/eh QfGQ5Qc8GU8umhMtUtz3Uo3Oj13C/MiPHbBo99Te7xBmqA1GF2fAKxGJeGPE3e15HAhe 2ikqRaxGF1CqbGFUdx0DwVLx7ir2vgnci67oIjVBpuD2rQs1GOSwm5igl7iSTzfDEtdk NwsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=vos3JDbeX3FffRQPJMt2+Q8iHjLNBl+4glU0COQrbaY=; b=hORv5Mr27y2bbsV7JhGF3zZkhv/lRn6e3KRqIxbPtZNyMjxZ+1/MJmoKQgzyym88+J Y+dsAJKQtT5HcG6VqF2x4XzcCCzglJs619GgHu37iDPJtaz9q/UgWFX+Fw77W0IenGW/ 39s9kEXdrOQu7E8YaG/vM6OzS/7rZnAs+m2+jFb3OoXPmjZxamwHAlgeaNbR6bkY7rLY W5TG8T4laMftzkEsyAOu94wZ5ulWLYuuNAMNzJPQMT3gXNu1GchAv/Yy9sctjpMlWf24 MxcsV3PitwoqWhpWtwaLVgDJLaMCzvQUgziQ7FF8JVvzVMKDv5KBqUKu2wyGZvwBsB+y uflA== ARC-Authentication-Results: i=1; mx.google.com; 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 j9-v6si5756441plt.497.2018.08.24.03.10.04; Fri, 24 Aug 2018 03:10:20 -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; 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 S1726633AbeHXNmw (ORCPT + 99 others); Fri, 24 Aug 2018 09:42:52 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:10421 "EHLO cmccmta3.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726243AbeHXNmv (ORCPT ); Fri, 24 Aug 2018 09:42:51 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.13]) by rmmx-syy-dmz-app12-12012 (RichMail) with SMTP id 2eec5b7fd9284e7-dc1bd; Fri, 24 Aug 2018 18:08:40 +0800 (CST) X-RM-TRANSID: 2eec5b7fd9284e7-dc1bd X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from [172.20.21.81] (unknown[112.25.154.148]) by rmsmtp-syy-appsvr07-12007 (RichMail) with SMTP id 2ee75b7fd926b29-49d4b; Fri, 24 Aug 2018 18:08:40 +0800 (CST) X-RM-TRANSID: 2ee75b7fd926b29-49d4b Subject: Re: [PATCH] staging: greybus: Fix null pointer dereference To: Johan Hovold Cc: elder@kernel.org, gregkh@linuxfoundation.org, greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Viresh Kumar References: <1535083631-1892-1-git-send-email-dingxiang@cmss.chinamobile.com> <20180824062930.GS14967@localhost> From: Ding Xiang Message-ID: Date: Fri, 24 Aug 2018 18:08:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180824062930.GS14967@localhost> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Johan     sorry, it's my fault. On 8/24/2018 2:29 PM, Johan Hovold wrote: > On Fri, Aug 24, 2018 at 12:07:11AM -0400, Ding Xiang wrote: >> If fw is null then fw->size will trigger null pointer dereference >> >> Signed-off-by: Ding Xiang >> --- >> drivers/staging/greybus/bootrom.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/staging/greybus/bootrom.c b/drivers/staging/greybus/bootrom.c >> index e85ffae..3af28a0 100644 >> --- a/drivers/staging/greybus/bootrom.c >> +++ b/drivers/staging/greybus/bootrom.c >> @@ -297,7 +297,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op) >> >> queue_work: >> /* Refresh timeout */ >> - if (!ret && (offset + size == fw->size)) >> + if (!ret && fw && (offset + size == fw->size)) >> next_request = NEXT_REQ_READY_TO_BOOT; >> else >> next_request = NEXT_REQ_GET_FIRMWARE; > How could fw be NULL when ret is 0 here? > > It may not be as obvious as one might have wished, but the current code > looks correct to me. > > Johan >