Re: [PATCH] Fix ide-disk.c oops caused by hwif == NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 9 Aug 2005, Linux Kernel Mailing List wrote:
> tree 518f62158f0923573decb8f072ac7282fb7575cb
> parent aeb3f76350e78aba90653b563de6677b442d21d6
> author Christoph Lameter <[email protected]> Wed, 10 Aug 2005 09:59:21 -0700
> committer Linus Torvalds <[email protected]> Wed, 10 Aug 2005 10:21:31 -0700
> 
> [PATCH] Fix ide-disk.c oops caused by hwif == NULL

How can this patch fix that? It still dereferences hwif without checking for a
NULL pointer.

> 1. Move hwif_to_node to ide.h
> 
> 2. Use hwif_to_node in ide-disk.c
> 
> Signed-off-by: Christoph Lameter <[email protected]>
> Signed-off-by: Linus Torvalds <[email protected]>
> 
>  drivers/ide/ide-disk.c  |    2 +-
>  drivers/ide/ide-probe.c |    9 ---------
>  include/linux/ide.h     |    6 ++++++
>  3 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
> --- a/drivers/ide/ide-disk.c
> +++ b/drivers/ide/ide-disk.c
> @@ -1220,7 +1220,7 @@ static int ide_disk_probe(struct device 
>  		goto failed;
>  
>  	g = alloc_disk_node(1 << PARTN_BITS,
> -			pcibus_to_node(drive->hwif->pci_dev->bus));
> +			hwif_to_node(drive->hwif));
>  	if (!g)
>  		goto out_free_idkp;
>  
> diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
> --- a/drivers/ide/ide-probe.c
> +++ b/drivers/ide/ide-probe.c
> @@ -960,15 +960,6 @@ static void save_match(ide_hwif_t *hwif,
>  }
>  #endif /* MAX_HWIFS > 1 */
>  
> -static inline int hwif_to_node(ide_hwif_t *hwif)
> -{
> -	if (hwif->pci_dev)
> -		return pcibus_to_node(hwif->pci_dev->bus);
> -	else
> -		/* Add ways to determine the node of other busses here */
> -		return -1;
> -}
> -
>  /*
>   * init request queue
>   */
> diff --git a/include/linux/ide.h b/include/linux/ide.h
> --- a/include/linux/ide.h
> +++ b/include/linux/ide.h
> @@ -1501,4 +1501,10 @@ extern struct bus_type ide_bus_type;
>  #define ide_id_has_flush_cache_ext(id)	\
>  	(((id)->cfs_enable_2 & 0x2400) == 0x2400)
>  
> +static inline int hwif_to_node(ide_hwif_t *hwif)
> +{
> +	struct pci_dev *dev = hwif->pci_dev;
                              ^^^^^^^^^^^^^
> +	return dev ? pcibus_to_node(dev->bus) : -1;
> +}
> +
>  #endif /* _IDE_H */

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux