Re: [libvirt] [PATCH 5/7] qemudDomainAttachSCSIDisk: avoid FP NULL-ptr-deref from clang

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

 



On Wed, Apr 14, 2010 at 06:02:34PM +0200, Jim Meyering wrote:
> From: Jim Meyering <meyering@xxxxxxxxxx>
> 
> * src/qemu/qemu_driver.c (qemudDomainAttachSCSIDisk):
> Initialize "cont" to NULL, so clang knows it's set.
> Add an sa_assert so it knows it's non-NULL when dereferenced.
> ---
>  src/qemu/qemu_driver.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index df1d435..f5cf1f1 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6851,7 +6851,7 @@ static int qemudDomainAttachSCSIDisk(struct qemud_driver *driver,
>  {
>      int i;
>      qemuDomainObjPrivatePtr priv = vm->privateData;
> -    virDomainControllerDefPtr cont;
> +    virDomainControllerDefPtr cont = NULL;
>      char *drivestr = NULL;
>      char *devstr = NULL;
>      int ret = -1;
> @@ -6894,6 +6894,11 @@ static int qemudDomainAttachSCSIDisk(struct qemud_driver *driver,
>              goto error;
>      }
> 
> +    /* Tell clang that "cont" is non-NULL.
> +       This is because disk->info.addr.driver.controller is unsigned,
> +       and hence the above loop must iterate at least once.  */
> +    sa_assert (cont);
> +
>      if (cont->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
>          qemuReportError(VIR_ERR_INTERNAL_ERROR,
>                          _("SCSI controller %d was missing its PCI address"), cont->idx);

ACK

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]