Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 281dbe5d authored by Ilya Dryomov's avatar Ilya Dryomov
Browse files

libceph: add an ONSTACK initializer for oids



An on-stack oid in ceph_ioctl_get_dataloc() is not initialized,
resulting in a WARN and a NULL pointer dereference later on.  We will
have more of these on-stack in the future, so fix it with a convenience
macro.

Fixes: d30291b9 ("libceph: variable-sized ceph_object_id")
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent b2aa5d0b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -183,7 +183,7 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
	struct ceph_osd_client *osdc =
	struct ceph_osd_client *osdc =
		&ceph_sb_to_client(inode->i_sb)->client->osdc;
		&ceph_sb_to_client(inode->i_sb)->client->osdc;
	struct ceph_object_locator oloc;
	struct ceph_object_locator oloc;
	struct ceph_object_id oid;
	CEPH_DEFINE_OID_ONSTACK(oid);
	u64 len = 1, olen;
	u64 len = 1, olen;
	u64 tmp;
	u64 tmp;
	struct ceph_pg pgid;
	struct ceph_pg pgid;
+5 −0
Original line number Original line Diff line number Diff line
@@ -115,6 +115,11 @@ static inline void ceph_oid_init(struct ceph_object_id *oid)
	oid->name_len = 0;
	oid->name_len = 0;
}
}


#define CEPH_OID_INIT_ONSTACK(oid)					\
    ({ ceph_oid_init(&oid); oid; })
#define CEPH_DEFINE_OID_ONSTACK(oid)					\
	struct ceph_object_id oid = CEPH_OID_INIT_ONSTACK(oid)

static inline bool ceph_oid_empty(const struct ceph_object_id *oid)
static inline bool ceph_oid_empty(const struct ceph_object_id *oid)
{
{
	return oid->name == oid->inline_name && !oid->name_len;
	return oid->name == oid->inline_name && !oid->name_len;