Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2675977imm; Fri, 24 Aug 2018 03:29:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYMw1J8+3O/5e/ylBAlgJpbKK+r9K5Pw/ujUsu4oUw34iJZQfgfDaWYR01DhKE/uyhziGoH X-Received: by 2002:a17:902:6b0b:: with SMTP id o11-v6mr1111480plk.214.1535106567622; Fri, 24 Aug 2018 03:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535106567; cv=none; d=google.com; s=arc-20160816; b=V0MQUoWnDG5CBrpD1uurauYu1zh3BzK8rJSL4SHLhMJJHBLyVhDlb14BdTcqqLx1T0 tdo+o9LdoOucBN6R5UYXaYSoXyPL4MEG5BbSK8yShu+0r40WfuJdy+TMXC8g/uO3grBd gaGP8vzsrmqRx5MqTBbeGa1cM4zXKHIXkkRu4mnoz0LjkSoOenOWZjSL4msndNHPIttx EN/jhxTDKw1PeOXOCgTJQO2swKtAp7xVX43EZOtobyzwRS5J0AbRbVBQdbs/FAO3Xu1/ 62i661hocpc6TRVglb099JJD+MTPTJnA1fRElyQxY9PVrQWoiaEyY2GqqE3Le5UIb5RN q7rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=xw9BLvZTOv+udwHSCVFPQjCzN1AaOvfb8sAEH2BgcBM=; b=ZFLpfpMohmSNGdGlniN0869+iWkcOa+GXDshbbA4ELzPW/B05vr2pO7HR0jEc9VBub 0C9iJARkKrLz7axKJtUocRvRyALdhOUIu8TnQIfMPqWqEsQpP3m+kCG9x5hmhYudTDhT c9q5RtN/ugGWmVqb8AYUmt8kCo2Szk3kEtE37AQ2cTT8PUVBoQEMwE7P20gS8SpQM86O oOdNeyNzWVTJ/VOvNzu0FvKMMZcKDEDp2b+U/c2JzHDX89fpG54kjC0m9vpzTe/UslT4 2V9WWpNUh5cYJiq/kV5Ppfx0TPC9ofq2UE/2dN6o5m2nVcvLJnuccFesq4l9w0c5ABo+ BvxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=cTr2G3t0; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x18-v6si6341098pll.88.2018.08.24.03.29.09; Fri, 24 Aug 2018 03:29:27 -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=@oracle.com header.s=corp-2018-07-02 header.b=cTr2G3t0; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbeHXOBy (ORCPT + 99 others); Fri, 24 Aug 2018 10:01:54 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:46404 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbeHXOBy (ORCPT ); Fri, 24 Aug 2018 10:01:54 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7OAOmXQ169605; Fri, 24 Aug 2018 10:27:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=xw9BLvZTOv+udwHSCVFPQjCzN1AaOvfb8sAEH2BgcBM=; b=cTr2G3t0GgOesgvy1TkNOfISlBeWFeg8ggah+XiUvKlSqKrdgdN5CuPTu6uW0ZGavF5w QjVOd58+nMHC9rXgUwUQtHYLWka+pBrTK6XHwEyePu+j8ZIxxrNXS+v1p2bUaodTPN8h iSKp1K3J1gDVeEn4cxaekCSSOkV5PNHxmypI/ytY5Zt1jQcCxWnt7s/YFwR+Jpk2S5au 9XRZtB5j5Eparff87H5pf0qgxr8fUm5DzUiiiA94/OBdfqe/LB6U+uFe+a3MosLzEG4c dCpDkajtkeT4bMM7ANAkRAOrnjH4ARma1g2rmnZaX7y69jFKViuNxn7wAuoXzRajkndc fA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2kxbdqebu7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Aug 2018 10:27:35 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7OARX9R015311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Aug 2018 10:27:33 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7OARV6x014004; Fri, 24 Aug 2018 10:27:32 GMT Received: from mwanda (/197.232.248.111) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 24 Aug 2018 10:27:31 +0000 Date: Fri, 24 Aug 2018 13:27:24 +0300 From: Dan Carpenter To: Ding Xiang Cc: johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org, greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: greybus: Fix null pointer dereference Message-ID: <20180824102723.zvzeaf26q6x7o3ms@mwanda> References: <1535083631-1892-1-git-send-email-dingxiang@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1535083631-1892-1-git-send-email-dingxiang@cmss.chinamobile.com> User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8994 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808240113 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)) That is impossible. If "ret" is zero that implies "fw" is a valid pointer. regards, dan carpenter