Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp399710pxu; Tue, 5 Jan 2021 14:27:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxMZRJq9gMir5KRM/jQUFWm/o4eBwB94HKQF+B9/wYuTrSzn3SVhFc51zltjrNYmPTLo13 X-Received: by 2002:a17:907:da7:: with SMTP id go39mr1088259ejc.58.1609885637209; Tue, 05 Jan 2021 14:27:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609885637; cv=none; d=google.com; s=arc-20160816; b=NZnPSwCkx1NMTLnFhlCXJ/FdEPnI5/pCAys+KODmCvbynmt6UgFzMqlSfk76AzdsqO lj6cEjhySD1Rr1iCwN4PFLKOFbf4WaWmyYlbb0x9YfFMYRdboLrACwffCO19kdbUnPDz vceeVZpu/wWCMrL/et7y3SPD5SzpbKjsDFl+ILZIc4r2d/cPMFalH+V1amMjDhYWPetq 1mcLaIG1ZaQ6CTaB+fTSLcR758CadTnKeh6GrUcn6r24vo/IYvnBRk2Fd04GIKMDR6+P IYblWQV52FpsgpeTeOVGiLaC8zWq9hVoveN6qXjCbu6vVAykki3gVPBFit80FgerYXwA IlBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pApZtT3kUoc3iG8fxyNumTsrhIoA70XGH4vOpczgKSg=; b=IrsUWZj1zxOb6OgmJCNchYOVZ5FHo+vRXVQ57iZwZdXq8uYLS4nt6cb89LO1OVHoIG hkW9ghCufJed9AjRRVSZXaMNjTITBlM+IB3fRkfHZ6Y0IqTW1eGir4r16zq7QoG+O3iq vw6swWpGAv46CszkZeBkMqH5JQQZhVAMGRN0MBn4l30+ZGFv7ePipgX9UHcXQZ8+A+EA 5YjcTKY4QQwvYTzW3PSR8gKLB2cYBZHkABsIlw1jxT0fZ2kRxPh1XQT490m5/YHJNQt/ jErMDZKHo1tukGFbsVkgfWqhz0erDY4scPX/bDpcdW4x7hz6KFkBe225+SBMJW6zC2vA TBEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GFG4+jX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si231632ejk.426.2021.01.05.14.26.53; Tue, 05 Jan 2021 14:27:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GFG4+jX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730539AbhAETUs (ORCPT + 99 others); Tue, 5 Jan 2021 14:20:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726234AbhAETUs (ORCPT ); Tue, 5 Jan 2021 14:20:48 -0500 Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44C91C061795 for ; Tue, 5 Jan 2021 11:20:07 -0800 (PST) Received: by mail-oo1-xc2c.google.com with SMTP id j21so195464oou.11 for ; Tue, 05 Jan 2021 11:20:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=pApZtT3kUoc3iG8fxyNumTsrhIoA70XGH4vOpczgKSg=; b=GFG4+jX20prcNuncQrsCbCXaDE1/+gSTKbaKjfYpz+g0RCZIbl4pXANTxdKUdUTmHS lYnsCEF966ZB+WYWeLXJI5CTuI4zriBu1UQ4Xc02Zuuo6RUFjeJzXQazknR4gKhGe+fC 3pPWITGRrA3Ktne+C44Q7JHlkdxng69Cw67wRXX3/ejaBneJgkyykaqaprrnUm7Tr54m 0X3tzTP4wrhtMOt1hZFzo7MKIenhTCcdq+DUtEoXASuzsXgY4zHSi92BJ8HQdUhhbhjg chjSOgT7DKZBh+45Ve9DBTxsBmtYtM4IB7XZHzo3IM+dMAOuw43CyXk1+hD5ezrL2lpu dZ4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pApZtT3kUoc3iG8fxyNumTsrhIoA70XGH4vOpczgKSg=; b=cYGXTug5ThQtgEe3V0I55u6LXqAlLI/m3fGaePi01Bg268c/vJVCPZrqwQ18A5aPhE JbeyVcqRsaIZsquXZH5iwF/JFBE7nyRMcH6rvCRFJ34k/nflThLSQu+eobjXCTKa71O7 pbwZEGVW5qzr9dDhi4b+ROFl8rnKPg5wEx8UTzXlz1ntgkNKBjFOa7w937r/XtXlQfyC Ze+DP12Zhz6p2fQ00AWP3RB1RjELiaz2CkpiYLVWAd0NlXJ0tfeUBBAIORZ3zpJSS6AV +3StM9K8qzqktcQ4JeGxHalZvsZwKBGGBdugWRPS8VeU9xfAqxsOsQKwPyu/EjUb2+QH 6EXw== X-Gm-Message-State: AOAM532ABJquoyFr/j31sN7yufeamqbFEmkiqJISDMafpjPWkvv7woaE /pYcXIKgQxUoyStXkKGKg9hCFg== X-Received: by 2002:a05:6820:441:: with SMTP id p1mr408451oou.21.1609874406662; Tue, 05 Jan 2021 11:20:06 -0800 (PST) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id g21sm23083otj.77.2021.01.05.11.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 11:20:05 -0800 (PST) Date: Tue, 5 Jan 2021 13:20:04 -0600 From: Bjorn Andersson To: Md Sadre Alam Cc: adrian.hunter@intel.com, ulf.hansson@linaro.org, linux-arm-msm@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, sricharan@codeaurora.org Subject: Re: [PATCH] mmc: sdhci-msm: Fix possible NULL pointer exception Message-ID: References: <1608626913-16675-1-git-send-email-mdalam@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1608626913-16675-1-git-send-email-mdalam@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 22 Dec 02:48 CST 2020, Md Sadre Alam wrote: > of_device_get_match_data returns NULL when no match. > So add the NULL pointer check to avoid dereference. > > Signed-off-by: Md Sadre Alam > --- > drivers/mmc/host/sdhci-msm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c > index 9c7927b..f20e424 100644 > --- a/drivers/mmc/host/sdhci-msm.c > +++ b/drivers/mmc/host/sdhci-msm.c > @@ -2235,6 +2235,8 @@ static int sdhci_msm_probe(struct platform_device *pdev) > * the data associated with the version info. > */ > var_info = of_device_get_match_data(&pdev->dev); > + if (!var_info) To get this you (the SDHCI driver developer) needs to add an entry in sdhci_msm_dt_match[] without a .data specified. > + goto pltfm_free; And this will cause sdhci_msm_probe() to return 0, giving no hint to said developer that they screwed up. Given that this can only be caused by a developer working on this driver you should provide feedback suitable for such developer, e.g. by: if (WARN_ON(!var_info)) return -EINVAL; But given that this is only for the developer himself, I don't see that this adds any value over just reading the callstack you get from the panic when the next line dereferences var_info (NULL). Regards, Bjorn > > msm_host->mci_removed = var_info->mci_removed; > msm_host->restore_dll_config = var_info->restore_dll_config; > -- > 2.7.4 >