From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Lothar Waßmann
<LW-bxm8fMRDkQLDiMYJYoSAnRvVK+yQ3ZXh@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
Juergen Beisert <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
Lothar Waßmann
<LW-bxm8fMRDkQLDiMYJYoSAnRvVK+yQ3ZXh@public.gmane.org>
Subject: Re: [PATCH] spi/imx: prevent NULL pointer dereference in spi_imx_probe()
Date: Tue, 03 Apr 2012 16:27:00 -0700 [thread overview]
Message-ID: <20120403232701.0A50A3E03F3@localhost> (raw)
In-Reply-To: <1333458224-7602-1-git-send-email-LW-bxm8fMRDkQLDiMYJYoSAnRvVK+yQ3ZXh@public.gmane.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1896 bytes --]
On Tue, 3 Apr 2012 15:03:44 +0200, Lothar Waßmann <LW-bxm8fMRDkQLDiMYJYoSAnRvVK+yQ3ZXh@public.gmane.org> wrote:
> When no platform_data is present and either 'spi-num-chipselects' is
> not defined in the DT or 'cs-gpios' has less entries than
> 'spi-num-chipselects' specifies, the NULL platform_data pointer is
> being dereferenced.
>
> Signed-off-by: Lothar Waßmann <LW-bxm8fMRDkQLDiMYJYoSAnRvVK+yQ3ZXh@public.gmane.org>
Applied, thanks.
g.
> ---
> drivers/spi/spi-imx.c | 10 +++++++---
> 1 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index 373f4ff..570f220 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -766,8 +766,12 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
> }
>
> ret = of_property_read_u32(np, "fsl,spi-num-chipselects", &num_cs);
> - if (ret < 0)
> - num_cs = mxc_platform_info->num_chipselect;
> + if (ret < 0) {
> + if (mxc_platform_info)
> + num_cs = mxc_platform_info->num_chipselect;
> + else
> + return ret;
> + }
>
> master = spi_alloc_master(&pdev->dev,
> sizeof(struct spi_imx_data) + sizeof(int) * num_cs);
> @@ -784,7 +788,7 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
>
> for (i = 0; i < master->num_chipselect; i++) {
> int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
> - if (cs_gpio < 0)
> + if (cs_gpio < 0 && mxc_platform_info)
> cs_gpio = mxc_platform_info->chipselect[i];
>
> spi_imx->chipselect[i] = cs_gpio;
> --
> 1.7.2.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.
[-- Attachment #2: Type: text/plain, Size: 274 bytes --]
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
[-- Attachment #3: Type: text/plain, Size: 210 bytes --]
_______________________________________________
spi-devel-general mailing list
spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/spi-devel-general
prev parent reply other threads:[~2012-04-03 23:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-03 13:03 [PATCH] spi/imx: prevent NULL pointer dereference in spi_imx_probe() Lothar Waßmann
[not found] ` <1333458224-7602-1-git-send-email-LW-bxm8fMRDkQLDiMYJYoSAnRvVK+yQ3ZXh@public.gmane.org>
2012-04-03 23:27 ` Grant Likely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120403232701.0A50A3E03F3@localhost \
--to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
--cc=LW-bxm8fMRDkQLDiMYJYoSAnRvVK+yQ3ZXh@public.gmane.org \
--cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).