* re: xen/acpi: ACPI memory hotplug
@ 2013-02-15 14:17 Dan Carpenter
2013-02-17 7:25 ` Liu, Jinsong
2013-02-17 7:25 ` Liu, Jinsong
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2013-02-15 14:17 UTC (permalink / raw)
To: jinsong.liu; +Cc: kbuild, xen-devel, virtualization
Hello Liu Jinsong,
This is a semi-automatic email about new static checker warnings.
The patch 259f201cb7ea: "xen/acpi: ACPI memory hotplug" from Jan 24,
2013, leads to the following Smatch complaint:
drivers/xen/xen-acpi-memhotplug.c:198 acpi_memory_get_device()
error: we previously assumed 'device' could be null (see line 171)
drivers/xen/xen-acpi-memhotplug.c
170
171 if (!acpi_bus_get_device(handle, &device) && device)
^^^^^^
New check.
Btw, checking device is unnecessary.
if (acpi_bus_get_device(handle, &device) == 0)
goto end;
A successful "Get Device" means that "device" is non-NULL; that's built
into the name. Anyway, if acpi_bus_get_device() fails either something
else will fail or we will Oops in the call to acpi_driver_data().
172 goto end;
173
174 status = acpi_get_parent(handle, &phandle);
175 if (ACPI_FAILURE(status)) {
176 pr_warn(PREFIX "Cannot find acpi parent\n");
177 return -EINVAL;
178 }
179
180 /* Get the parent device */
181 result = acpi_bus_get_device(phandle, &pdevice);
182 if (result) {
183 pr_warn(PREFIX "Cannot get acpi bus device\n");
184 return -EINVAL;
185 }
186
187 /*
188 * Now add the notified device. This creates the acpi_device
189 * and invokes .add function
190 */
191 result = acpi_bus_scan(handle);
192 if (result) {
193 pr_warn(PREFIX "Cannot add acpi bus\n");
194 return -EINVAL;
195 }
196
197 end:
198 *mem_device = acpi_driver_data(device);
^^^^^^
Dereference.
199 if (!(*mem_device)) {
200 pr_err(PREFIX "Driver data not found\n");
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: xen/acpi: ACPI memory hotplug
2013-02-15 14:17 xen/acpi: ACPI memory hotplug Dan Carpenter
2013-02-17 7:25 ` Liu, Jinsong
@ 2013-02-17 7:25 ` Liu, Jinsong
1 sibling, 0 replies; 3+ messages in thread
From: Liu, Jinsong @ 2013-02-17 7:25 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kbuild, xen-devel, virtualization
Dan Carpenter wrote:
> Hello Liu Jinsong,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 259f201cb7ea: "xen/acpi: ACPI memory hotplug" from Jan 24,
> 2013, leads to the following Smatch complaint:
>
> drivers/xen/xen-acpi-memhotplug.c:198 acpi_memory_get_device()
> error: we previously assumed 'device' could be null (see line 171)
>
> drivers/xen/xen-acpi-memhotplug.c
> 170
> 171 if (!acpi_bus_get_device(handle, &device) && device)
> ^^^^^^
> New check.
>
> Btw, checking device is unnecessary.
>
> if (acpi_bus_get_device(handle, &device) == 0)
> goto end;
>
> A successful "Get Device" means that "device" is non-NULL; that's
> built into the name. Anyway, if acpi_bus_get_device() fails either
> something else will fail or we will Oops in the call to
> acpi_driver_data().
>
> 172 goto end;
> 173
> 174 status = acpi_get_parent(handle, &phandle);
> 175 if (ACPI_FAILURE(status)) {
> 176 pr_warn(PREFIX "Cannot find acpi parent\n");
> 177 return -EINVAL;
> 178 }
> 179
> 180 /* Get the parent device */
> 181 result = acpi_bus_get_device(phandle, &pdevice);
> 182 if (result) {
> 183 pr_warn(PREFIX "Cannot get acpi bus device\n");
> 184 return -EINVAL;
> 185 }
> 186
> 187 /*
> 188 * Now add the notified device. This creates the acpi_device
> 189 * and invokes .add function
> 190 */
> 191 result = acpi_bus_scan(handle);
> 192 if (result) {
> 193 pr_warn(PREFIX "Cannot add acpi bus\n");
> 194 return -EINVAL;
> 195 }
> 196
> 197 end:
> 198 *mem_device = acpi_driver_data(device);
> ^^^^^^
> Dereference.
>
> 199 if (!(*mem_device)) {
> 200 pr_err(PREFIX "Driver data not found\n");
>
> regards,
> dan carpenter
Thanks Dan, updated, will send out minutes later.
Regards,
Jinsong
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: xen/acpi: ACPI memory hotplug
2013-02-15 14:17 xen/acpi: ACPI memory hotplug Dan Carpenter
@ 2013-02-17 7:25 ` Liu, Jinsong
2013-02-17 7:25 ` Liu, Jinsong
1 sibling, 0 replies; 3+ messages in thread
From: Liu, Jinsong @ 2013-02-17 7:25 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kbuild, xen-devel, virtualization
Dan Carpenter wrote:
> Hello Liu Jinsong,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 259f201cb7ea: "xen/acpi: ACPI memory hotplug" from Jan 24,
> 2013, leads to the following Smatch complaint:
>
> drivers/xen/xen-acpi-memhotplug.c:198 acpi_memory_get_device()
> error: we previously assumed 'device' could be null (see line 171)
>
> drivers/xen/xen-acpi-memhotplug.c
> 170
> 171 if (!acpi_bus_get_device(handle, &device) && device)
> ^^^^^^
> New check.
>
> Btw, checking device is unnecessary.
>
> if (acpi_bus_get_device(handle, &device) == 0)
> goto end;
>
> A successful "Get Device" means that "device" is non-NULL; that's
> built into the name. Anyway, if acpi_bus_get_device() fails either
> something else will fail or we will Oops in the call to
> acpi_driver_data().
>
> 172 goto end;
> 173
> 174 status = acpi_get_parent(handle, &phandle);
> 175 if (ACPI_FAILURE(status)) {
> 176 pr_warn(PREFIX "Cannot find acpi parent\n");
> 177 return -EINVAL;
> 178 }
> 179
> 180 /* Get the parent device */
> 181 result = acpi_bus_get_device(phandle, &pdevice);
> 182 if (result) {
> 183 pr_warn(PREFIX "Cannot get acpi bus device\n");
> 184 return -EINVAL;
> 185 }
> 186
> 187 /*
> 188 * Now add the notified device. This creates the acpi_device
> 189 * and invokes .add function
> 190 */
> 191 result = acpi_bus_scan(handle);
> 192 if (result) {
> 193 pr_warn(PREFIX "Cannot add acpi bus\n");
> 194 return -EINVAL;
> 195 }
> 196
> 197 end:
> 198 *mem_device = acpi_driver_data(device);
> ^^^^^^
> Dereference.
>
> 199 if (!(*mem_device)) {
> 200 pr_err(PREFIX "Driver data not found\n");
>
> regards,
> dan carpenter
Thanks Dan, updated, will send out minutes later.
Regards,
Jinsong
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-17 7:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-15 14:17 xen/acpi: ACPI memory hotplug Dan Carpenter
2013-02-17 7:25 ` Liu, Jinsong
2013-02-17 7:25 ` Liu, Jinsong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.