obj: Fix dereference before NULL check

The check for !obj indicates that obj might be NULL, thus move the call
to obj_ops(obj) - which dereferences obj - after the check.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Tobias Klauser 2014-06-03 10:47:48 +02:00 committed by Thomas Haller
parent 732c19948d
commit 1087eb5314

View file

@ -110,13 +110,14 @@ struct nl_derived_object {
struct nl_object *nl_object_clone(struct nl_object *obj)
{
struct nl_object *new;
struct nl_object_ops *ops = obj_ops(obj);
struct nl_object_ops *ops;
int doff = offsetof(struct nl_derived_object, data);
int size;
if (!obj)
return NULL;
ops = obj_ops(obj);
new = nl_object_alloc(ops);
if (!new)
return NULL;