Re: sony-laptop: fix early NULL pointer dereference

From: Thiago Farina
Date: Mon Apr 04 2011 - 20:26:09 EST


On Mon, Apr 4, 2011 at 8:44 PM, Mattia Dongili <malattia@xxxxxxxx> wrote:
> Author: Mattia Dongili <malattia@xxxxxxxx>
> Date: Â Fri Apr 1 10:01:41 2011 +0900
>
I think most of the patches doesn't include these above lines nor the
subject line in the description. Also when submitting a patch to the
list, please don't forget to put [PATCH] on the subject line.

git format-patch should output the right format.

> Â Âsony-laptop: fix early NULL pointer dereference
>
> Â ÂThe SNC acpi driver could get early notifications before it fully
> Â Âinitializes and that could lead to dereferencing the sony_nc_handles
> Â Âstructure pointer that is still NULL at that stage.
> Â ÂMake sure we return early from the handle lookup function in these
> Â Âcases.
>
> Â ÂSigned-off-by: Mattia Dongili <malattia@xxxxxxxx>
> ---
>
> Hi Matthew,
> if it's not too late, can you pick this one up instead of the previous
> one (89ec2feafaedd759e53346d641f60863a14cfb9e)?
> If it's too late I'll try and do a round of return value fixes later.
>
> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
> index b2ce172..de79c18 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -810,6 +810,11 @@ static int sony_nc_handles_cleanup(struct platform_device *pd)
> Âstatic int sony_find_snc_handle(int handle)
> Â{
> Â Â Â Âint i;
> +
> + Â Â Â /* not initialized yet, return early */
This comment is useless, it is just repeating what the codes does ;) I
think you can just remove it.

> + Â Â Â if (!handles)
> + Â Â Â Â Â Â Â return -EINVAL;
> +
> Â Â Â Âfor (i = 0; i < 0x10; i++) {
> Â Â Â Â Â Â Â Âif (handles->cap[i] == handle) {
> Â Â Â Â Â Â Â Â Â Â Â Âdprintk("found handle 0x%.4x (offset: 0x%.2x)\n",
> --
> mattia
> :wq!
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/